Skip to content

Commit

Permalink
refactor(SchematicsCore): remove npm install task during ng update (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored and brandonroberts committed May 23, 2018
1 parent 440b6cf commit a478c0d
Show file tree
Hide file tree
Showing 24 changed files with 15 additions and 2,484 deletions.
9 changes: 1 addition & 8 deletions modules/effects/schematics-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ export {
ReplaceChange,
} from './utility/change';

export {
AppConfig,
CliConfig,
getAppFromConfig,
getConfig,
getWorkspace,
getWorkspacePath,
} from './utility/config';
export { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';

export {
findModule,
Expand Down
340 changes: 0 additions & 340 deletions modules/effects/schematics-core/utility/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,318 +126,6 @@ export interface AppConfig {
};
}

export interface CliConfig {
$schema?: string;
/**
* The global configuration of the project.
*/
project?: {
/**
* The name of the project.
*/
name?: string;
/**
* Whether or not this project was ejected.
*/
ejected?: boolean;
};
/**
* Properties of the different applications in this project.
*/
apps?: AppConfig[];
/**
* Configuration for end-to-end tests.
*/
e2e?: {
protractor?: {
/**
* Path to the config file.
*/
config?: string;
};
};
/**
* Properties to be passed to TSLint.
*/
lint?: {
/**
* File glob(s) to lint.
*/
files?: string | string[];
/**
* Location of the tsconfig.json project file.
* Will also use as files to lint if 'files' property not present.
*/
project: string;
/**
* Location of the tslint.json configuration.
*/
tslintConfig?: string;
/**
* File glob(s) to ignore.
*/
exclude?: string | string[];
}[];
/**
* Configuration for unit tests.
*/
test?: {
karma?: {
/**
* Path to the karma config file.
*/
config?: string;
};
codeCoverage?: {
/**
* Globs to exclude from code coverage.
*/
exclude?: string[];
};
};
/**
* Specify the default values for generating.
*/
defaults?: {
/**
* The file extension to be used for style files.
*/
styleExt?: string;
/**
* How often to check for file updates.
*/
poll?: number;
/**
* Use lint to fix files after generation
*/
lintFix?: boolean;
/**
* Options for generating a class.
*/
class?: {
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Options for generating a component.
*/
component?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
/**
* Specifies if the style will be in the ts file.
*/
inlineStyle?: boolean;
/**
* Specifies if the template will be in the ts file.
*/
inlineTemplate?: boolean;
/**
* Specifies the view encapsulation strategy.
*/
viewEncapsulation?: 'Emulated' | 'Native' | 'None';
/**
* Specifies the change detection strategy.
*/
changeDetection?: 'Default' | 'OnPush';
};
/**
* Options for generating a directive.
*/
directive?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Options for generating a guard.
*/
guard?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Options for generating an interface.
*/
interface?: {
/**
* Prefix to apply to interface names. (i.e. I)
*/
prefix?: string;
};
/**
* Options for generating a module.
*/
module?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Options for generating a pipe.
*/
pipe?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Options for generating a service.
*/
service?: {
/**
* Flag to indicate if a dir is created.
*/
flat?: boolean;
/**
* Specifies if a spec file is generated.
*/
spec?: boolean;
};
/**
* Properties to be passed to the build command.
*/
build?: {
/**
* Output sourcemaps.
*/
sourcemaps?: boolean;
/**
* Base url for the application being built.
*/
baseHref?: string;
/**
* The ssl key used by the server.
*/
progress?: boolean;
/**
* Enable and define the file watching poll time period (milliseconds).
*/
poll?: number;
/**
* Delete output path before build.
*/
deleteOutputPath?: boolean;
/**
* Do not use the real path when resolving modules.
*/
preserveSymlinks?: boolean;
/**
* Show circular dependency warnings on builds.
*/
showCircularDependencies?: boolean;
/**
* Use a separate bundle containing code used across multiple bundles.
*/
commonChunk?: boolean;
/**
* Use file name for lazy loaded chunks.
*/
namedChunks?: boolean;
};
/**
* Properties to be passed to the serve command.
*/
serve?: {
/**
* The port the application will be served on.
*/
port?: number;
/**
* The host the application will be served on.
*/
host?: string;
/**
* Enables ssl for the application.
*/
ssl?: boolean;
/**
* The ssl key used by the server.
*/
sslKey?: string;
/**
* The ssl certificate used by the server.
*/
sslCert?: string;
/**
* Proxy configuration file.
*/
proxyConfig?: string;
};
/**
* Properties about schematics.
*/
schematics?: {
/**
* The schematics collection to use.
*/
collection?: string;
/**
* The new app schematic.
*/
newApp?: string;
};
};
/**
* Specify which package manager tool to use.
*/
packageManager?: 'npm' | 'cnpm' | 'yarn' | 'default';
/**
* Allow people to disable console warnings.
*/
warnings?: {
/**
* Show a warning when the user enabled the --hmr option.
*/
hmrWarning?: boolean;
/**
* Show a warning when the node version is incompatible.
*/
nodeDeprecation?: boolean;
/**
* Show a warning when the user installed angular-cli.
*/
packageDeprecation?: boolean;
/**
* Show a warning when the global version is newer than the local one.
*/
versionMismatch?: boolean;
/**
* Show a warning when the TypeScript version is incompatible
*/
typescriptMismatch?: boolean;
};
}

export type WorkspaceSchema = experimental.workspace.WorkspaceSchema;

export function getWorkspacePath(host: Tree): string {
Expand All @@ -457,31 +145,3 @@ export function getWorkspace(host: Tree): WorkspaceSchema {

return JSON.parse(config);
}

export const configPath = '/.angular-cli.json';

export function getConfig(host: Tree): CliConfig {
const configBuffer = host.read(configPath);
if (configBuffer === null) {
throw new SchematicsException('Could not find .angular-cli.json');
}

const config = JSON.parse(configBuffer.toString());

return config;
}

export function getAppFromConfig(
config: CliConfig,
appIndexOrName: string
): AppConfig | null {
if (!config.apps) {
return null;
}

if (parseInt(appIndexOrName) >= 0) {
return config.apps[parseInt(appIndexOrName)];
}

return config.apps.filter(app => app.name === appIndexOrName)[0];
}
6 changes: 1 addition & 5 deletions modules/effects/schematics-core/utility/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import {
SchematicContext,
Tree,
SchematicsException,
chain,
} from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';

export function updatePackage(name: string): Rule {
return (tree: Tree, context: SchematicContext) => {
const pkgPath = '/package.json';
const buffer = tree.read(pkgPath);
if (buffer == null) {
if (buffer === null) {
throw new SchematicsException('Could not read package.json');
}
const content = buffer.toString();
Expand All @@ -30,13 +28,11 @@ export function updatePackage(name: string): Rule {
const firstChar = pkg[category][packageName][0];
const suffix = match(firstChar, '^') || match(firstChar, '~');

// TODO: remove beta
pkg[category][packageName] = `${suffix}6.0.0`;
}
});

tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
context.addTask(new NodePackageInstallTask());

return tree;
};
Expand Down
Loading

0 comments on commit a478c0d

Please sign in to comment.