@ng-atomic/schematics 1.3.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/collection.json +6 -0
  2. package/package.json +4 -1
  3. package/src/_utilities/angular-config.js +1 -1
  4. package/src/_utilities/angular-config.js.map +1 -1
  5. package/src/_utilities/save-file.d.ts +2 -0
  6. package/src/_utilities/save-file.js +11 -0
  7. package/src/_utilities/save-file.js.map +1 -0
  8. package/src/atomic-component/_test/example.atom.scss +6 -0
  9. package/src/atomic-component/_test/{example.atom.ts.expected → example.atom.ts} +3 -2
  10. package/src/atomic-component/index.js +14 -22
  11. package/src/atomic-component/index.js.map +1 -1
  12. package/src/atomic-component/index.spec.ts +31 -6
  13. package/src/atomic-component/schema.d.ts +1 -0
  14. package/src/atomic-component/schema.json +9 -4
  15. package/src/ng-add/index.js +3 -7
  16. package/src/ng-add/index.js.map +1 -1
  17. package/src/ng-add/schema.json +2 -2
  18. package/src/page/_test/{test.module.ts.expected → example.module.ts} +5 -5
  19. package/src/page/_test/example.page.scss +6 -0
  20. package/src/page/_test/example.page.ts +15 -0
  21. package/src/page/index.js +9 -7
  22. package/src/page/index.js.map +1 -1
  23. package/src/page/index.spec.ts +17 -9
  24. package/src/setup/files/atomic/_atom.scss +2 -3
  25. package/src/setup/files/atomic/_component.scss +1 -8
  26. package/src/setup/files/atomic/_molecule.scss +2 -3
  27. package/src/setup/files/atomic/_organism.scss +2 -3
  28. package/src/setup/files/atomic/_page.scss +2 -3
  29. package/src/setup/files/atomic/_template.scss +2 -3
  30. package/src/setup/index.spec.ts +5 -5
  31. package/src/style-header/_test/example.scss +6 -0
  32. package/src/style-header/index.d.ts +4 -0
  33. package/src/style-header/index.js +17 -0
  34. package/src/style-header/index.js.map +1 -0
  35. package/src/style-header/index.spec.ts +43 -0
  36. package/src/style-header/schema.d.ts +6 -0
  37. package/src/style-header/schema.js +3 -0
  38. package/src/style-header/schema.js.map +1 -0
  39. package/src/style-header/schema.json +22 -0
package/collection.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "extends": ["@schematics/angular"],
3
3
  "schematics": {
4
+ "style-header": {
5
+ "aliases": ["sh"],
6
+ "description": "Add style header",
7
+ "factory": "./src/style-header/index",
8
+ "schema": "./src/style-header/schema.json"
9
+ },
4
10
  "atomic-component": {
5
11
  "aliases": ["ac"],
6
12
  "description": "Create an atomic component",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-atomic/schematics",
3
- "version": "1.3.0",
3
+ "version": "1.6.0",
4
4
  "schematics": "./collection.json",
5
5
  "ng-add": {
6
6
  "save": "devDependencies"
@@ -8,6 +8,9 @@
8
8
  "main": "src/index.js",
9
9
  "typings": "src/index.d.ts",
10
10
  "dependencies": {
11
+ "@angular/core": "^11.2.0",
12
+ "@angular/common": "^11.2.0",
13
+ "@angular/router": "^11.2.0",
11
14
  "string-template": "^1.0.0"
12
15
  },
13
16
  "peerDependencies": {}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addStyleIncludePath = exports.setDefaultCollection = exports.addSchematicsConfig = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const overwrite_1 = require("./overwrite");
6
- const PACKAGE_NAME = 'angular-atomic-schematics';
6
+ const PACKAGE_NAME = '@ng-atomic/schematics';
7
7
  exports.addSchematicsConfig = ({ project, componentsDir }, type) => (host) => {
8
8
  const query = `projects.${project}.schematics.${PACKAGE_NAME}:${type}`;
9
9
  return overwrite_1.overwrite(host, 'angular.json', json => (lodash_1.set(json, query, { 'path': `${componentsDir}/${type}s` }), json));
@@ -1 +1 @@
1
- {"version":3,"file":"angular-config.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_utilities/angular-config.ts"],"names":[],"mappings":";;;AACA,mCAAkC;AAClC,2CAAwC;AAExC,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAEpC,QAAA,mBAAmB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C;AAEhC,QAAA,mBAAmB,GAAG,CAAC,EAAC,OAAO,EAAE,aAAa,EAAM,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAU,EAAQ,EAAE;IACxG,MAAM,KAAK,GAAG,YAAY,OAAO,eAAe,YAAY,IAAI,IAAI,EAAE,CAAC;IACvE,OAAO,qBAAS,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,YAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACjH,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAU,EAAE,EAAE;IACxD,OAAO,qBAAS,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,YAAG,CAAC,IAAI,EAAE,uBAAuB,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC1G,CAAC,CAAA;AAEY,QAAA,mBAAmB,GAAG,CAAC,EAAC,OAAO,EAAE,SAAS,EAAM,EAAE,EAAE,CAAC,CAAC,IAAU,EAAE,EAAE;IAChF,MAAM,KAAK,GAAG,YAAY,OAAO,gEAAgE,CAAC;IAClG,OAAO,qBAAS,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,YAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,YAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACzH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function saveFile(host: Tree, path: string, callback: (str: string) => string): Tree;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveFile = void 0;
4
+ function saveFile(host, path, callback) {
5
+ host.exists(path)
6
+ ? host.overwrite(path, callback(host.read(path).toString('utf-8')))
7
+ : host.create(path, callback(''));
8
+ return host;
9
+ }
10
+ exports.saveFile = saveFile;
11
+ //# sourceMappingURL=save-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-file.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_utilities/save-file.ts"],"names":[],"mappings":";;;AAEA,SAAgB,QAAQ,CAAC,IAAU,EAAE,IAAY,EAAE,QAAiC;IACnF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AACb,CAAC;AALD,4BAKC"}
@@ -0,0 +1,6 @@
1
+ @use 'scoped-var/strict' as * with ($host: 'example');
2
+ @use 'atomic/atom' as *;
3
+
4
+ :host {
5
+ @include atom($host);
6
+ }
@@ -1,9 +1,10 @@
1
- import { Component, OnInit } from '@angular/core';
1
+ import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
2
2
 
3
3
  @Component({
4
4
  selector: 'atoms-example',
5
5
  templateUrl: './example.atom.html',
6
- styleUrls: ['./example.atom.scss']
6
+ styleUrls: ['./example.atom.scss'],
7
+ changeDetection: ChangeDetectionStrategy.OnPush
7
8
  })
8
9
  export class ExampleAtom implements OnInit {
9
10
 
@@ -8,30 +8,22 @@ const parse_name_1 = require("@schematics/angular/utility/parse-name");
8
8
  const workspace_1 = require("@schematics/angular/utility/workspace");
9
9
  const path_1 = require("path");
10
10
  exports.atomicComponent = (options) => (host, _) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
- var _a, _b;
12
- (_a = options.prefix) !== null && _a !== void 0 ? _a : (options.prefix = 'extras');
13
- options.path = path_1.join(yield workspace_1.createDefaultPath(host, options.project), (_b = options === null || options === void 0 ? void 0 : options.path) !== null && _b !== void 0 ? _b : '');
14
- const { name, path, type } = options = Object.assign(Object.assign({}, options), parse_name_1.parseName(options.path, options.name));
15
- delete options.styleHeader;
11
+ var _a;
12
+ options.prefix || (options.prefix = `${options.type}s`);
13
+ options.path = path_1.join(yield workspace_1.createDefaultPath(host, options.project), (_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : '');
14
+ const { name, path, type, project } = options = Object.assign(Object.assign({}, options), parse_name_1.parseName(options.path, options.name));
15
+ const componentExt = options.useTypeAsExtension ? type : 'component';
16
+ const scssPath = `${path}/${name}/${name}.${componentExt}.scss`;
16
17
  return schematics_1.chain([
17
- schematics_1.externalSchematic('@schematics/angular', 'module', { name, path, project: options.project }),
18
- schematics_1.externalSchematic('@schematics/angular', 'component', Object.assign(Object.assign({}, options), { export: true })),
19
- // externalSchematic('angular-host-css-variable', 'component', {...options, styleHeader: format(options.styleHeader, { name, type }), export: true}),
18
+ schematics_1.externalSchematic('@schematics/angular', 'module', { name, path, project }),
19
+ schematics_1.externalSchematic('@schematics/angular', 'component', Object.assign(Object.assign({}, options), { type: componentExt, export: true })),
20
20
  schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [schematics_1.applyTemplates(Object.assign(Object.assign({}, strings), { name, type: type !== null && type !== void 0 ? type : 'component' })), schematics_1.move(path)])),
21
+ schematics_1.schematic('style-header', Object.assign(Object.assign({}, options), { name, type, path: scssPath })),
21
22
  ]);
22
23
  });
23
- exports.atom = (options) => exports.atomicComponent(buildOptions(options, 'atom'));
24
- exports.molecule = (options) => exports.atomicComponent(buildOptions(options, 'molecule'));
25
- exports.organism = (options) => exports.atomicComponent(buildOptions(options, 'organism'));
26
- exports.template = (options) => exports.atomicComponent(buildOptions(options, 'template'));
27
- exports.frame = (options) => exports.atomicComponent(buildOptions(options, 'frame'));
28
- const buildOptions = (options, type) => (Object.assign(Object.assign({}, options), { type: options.type || type, prefix: options.prefix || `${options.type || type}s` }));
29
- const addExportIntoIndexTs = ({ path, name }) => (tree) => {
30
- const indexTsPath = path_1.join(path, 'index.ts');
31
- tree.exists(indexTsPath) || tree.create(indexTsPath, '');
32
- const lines = tree.read(indexTsPath).toString('utf-8').split('\n').filter(line => line.length);
33
- const line = `export { ${strings.classify(name)}Module } from './${strings.dasherize(name)}';`;
34
- tree.overwrite(indexTsPath, (lines.includes(line) ? lines : [...lines, line]).join('\n'));
35
- return tree;
36
- };
24
+ exports.atom = (options) => exports.atomicComponent((Object.assign(Object.assign({}, options), { type: 'atom' })));
25
+ exports.molecule = (options) => exports.atomicComponent((Object.assign(Object.assign({}, options), { type: 'molecule' })));
26
+ exports.organism = (options) => exports.atomicComponent((Object.assign(Object.assign({}, options), { type: 'organism' })));
27
+ exports.template = (options) => exports.atomicComponent((Object.assign(Object.assign({}, options), { type: 'template' })));
28
+ exports.frame = (options) => exports.atomicComponent((Object.assign(Object.assign({}, options), { type: 'frame' })));
37
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/atomic-component/index.ts"],"names":[],"mappings":";;;;AAAA,2DAGoC;AACpC,kEAAkE;AAClE,uEAAmE;AACnE,qEAA0E;AAC1E,+BAA4B;AAGf,QAAA,eAAe,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAO,IAAU,EAAE,CAAmB,EAAE,EAAE;;IACnG,MAAA,OAAO,CAAC,MAAM,oCAAd,OAAO,CAAC,MAAM,GAAK,QAAQ,EAAC;IAC5B,OAAO,CAAC,IAAI,GAAG,WAAI,CAAC,MAAM,6BAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,QAAE,OAAO,a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AW,IAAE,EAAE,iBAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7G,sBAAS,CAAC,cAAc,kCAAM,OAAO,KAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,IAAE;KACnE,CAAC,CAAC;AACJ,CAAC,CAAA,CAAC;AAEW,QAAA,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,MAAM,IAAE,CAAC,CAAC;AAChF,QAAA,QAAQ,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,UAAU,IAAE,CAAC,CAAC;AACxF,QAAA,QAAQ,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,UAAU,IAAE,CAAC,CAAC;AACxF,QAAA,QAAQ,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,UAAU,IAAE,CAAC,CAAC;AACxF,QAAA,KAAK,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,OAAO,IAAE,CAAC,CAAC"}
@@ -56,8 +56,8 @@ describe('AtomicComponent Schematics', () => {
56
56
  expect(files).toContain('/projects/app/src/app/_shared/components/second/second.stories.ts');
57
57
  expect(files).toContain('/projects/app/src/app/_shared/components/second/index.ts');
58
58
 
59
- const source = tree.read('/projects/app/src/app/_shared/components/index.ts')!.toString('utf-8');
60
- expect(source).toEqual(`export { FirstModule } from './first';\nexport { SecondModule } from './second';`);
59
+ // const source = tree.read('/projects/app/src/app/_shared/components/index.ts')!.toString('utf-8');
60
+ // expect(source).toEqual(`export { FirstModule } from './first';\nexport { SecondModule } from './second';`);
61
61
  });
62
62
 
63
63
  it('should create atomic components files in app2', async () => {
@@ -66,7 +66,28 @@ describe('AtomicComponent Schematics', () => {
66
66
  const expectedFilePaths = buildExpectedFilePaths(options.name, 'example', projectPath, 'component');
67
67
 
68
68
  const { files } = await runner.runSchematicAsync('atomic-component', options, tree).toPromise();
69
- expectedFilePaths.forEach(path => expect(files.includes(path)).toBeTruthy());
69
+ expectedFilePaths.forEach(path => expect(files).toContain(path));
70
+ });
71
+
72
+ describe('given useTypeAsExtension is false', () => {
73
+ it('should output `example.component.ts`', async () => {
74
+ const options = {project: 'app2', name: '_shared/components/example', type: 'dialog', useTypeAsExtension: false};
75
+ const projectPath = getTestProjectPath(defaultWorkspaceOptions, {...defaultAppOptions, name: 'app2'});
76
+ const expectedFilePaths = buildExpectedFilePaths(options.name, 'example', projectPath, 'component');
77
+
78
+ tree = await runner.runSchematicAsync('atomic-component', options, tree).toPromise();
79
+ expectedFilePaths.forEach(path => expect(tree.files).toContain(path));
80
+
81
+ const inputScss = tree.read('/projects/app2/src/app/_shared/components/example/example.component.scss').toString('utf-8');
82
+ expect(inputScss.replace(/\s/g, '')).toEqual(`
83
+ @use 'scoped-var/strict' as * with ($host: 'example');
84
+ @use 'atomic/dialog' as *;
85
+
86
+ :host {
87
+ @include dialog($host);
88
+ }
89
+ `.replace(/\s/g, ''));
90
+ });
70
91
  });
71
92
  });
72
93
 
@@ -101,9 +122,13 @@ describe('Atom Schematics', () => {
101
122
  const host = await runner.runSchematicAsync('atom', options, tree).toPromise();
102
123
  expectedFilePaths.forEach(path => expect(host.files.includes(path)).toBeTruthy());
103
124
 
104
- const input = host.read('/projects/app/src/app/_shared/components/example/example.atom.ts').toString('utf-8');
105
- const expected = readFileSync(join(__dirname, '_test/example.atom.ts.expected')).toString();
106
- expect(input.replace(/\s/g, '')).toEqual(expected.replace(/\s/g, ''));
125
+ const inputTs = host.read('/projects/app/src/app/_shared/components/example/example.atom.ts').toString('utf-8');
126
+ const expectedTs = readFileSync(join(__dirname, '_test/example.atom.ts')).toString();
127
+ expect(inputTs.replace(/\s/g, '')).toEqual(expectedTs.replace(/\s/g, ''));
128
+
129
+ const inputScss = host.read('/projects/app/src/app/_shared/components/example/example.atom.scss').toString('utf-8');
130
+ const expectedScss = readFileSync(join(__dirname, '_test/example.atom.scss')).toString();
131
+ expect(inputScss.replace(/\s/g, '')).toEqual(expectedScss.replace(/\s/g, ''));
107
132
  });
108
133
  });
109
134
 
@@ -17,4 +17,5 @@ export interface Schema {
17
17
  module?: string;
18
18
  export?: boolean;
19
19
  styleHeader?: string;
20
+ useTypeAsExtension: boolean;
20
21
  }
@@ -51,7 +51,7 @@
51
51
  "description": "The change detection strategy to use in the new component.",
52
52
  "enum": ["Default", "OnPush"],
53
53
  "type": "string",
54
- "default": "Default",
54
+ "default": "OnPush",
55
55
  "alias": "c"
56
56
  },
57
57
  "prefix": {
@@ -122,9 +122,14 @@
122
122
  },
123
123
  "styleHeader": {
124
124
  "type": "string",
125
- "default": "@import 'host-variable';\n@import 'atomic/{type}';\n$host: host('{name}');\n\n:host {\n\t@include {type}($host);\n}\n",
126
- "description": ""
127
- }
125
+ "default": "@use 'scoped-var/strict' as * with ($host: '{name}');\n@use 'atomic/{type}' as *;\n:host {\n\t@include {type}($host);\n}\n",
126
+ "description": "scss header template. you can use template engine like `($host: '{name}.{type}'`. "
127
+ },
128
+ "useTypeAsExtension": {
129
+ "type": "boolean",
130
+ "default": true,
131
+ "description": "When false, atomic component extension should be `.component.ts`"
132
+ }
128
133
  },
129
134
  "required": [
130
135
  "name"
@@ -10,15 +10,11 @@ function default_1(options) {
10
10
  if (angularDependencyVersion === '0.0.0-NG') {
11
11
  throw new Error('@angular/core version is not supported.');
12
12
  }
13
- // 必要なパッケージの追加
14
- _utilities_1.addPackageToPackageJson(host, 'angular-atomic-schematics', getCustomWebpackVersion(angularDependencyVersion), 'devDependencies');
15
- _utilities_1.addPackageToPackageJson(host, 'angular-host-css-variable', getCustomWebpackVersion(angularDependencyVersion), 'devDependencies');
16
- _utilities_1.addPackageToPackageJson(host, 'angular-custom-webpack-chaining', getCustomWebpackVersion(angularDependencyVersion), 'devDependencies');
13
+ _utilities_1.addPackageToPackageJson(host, '@ng-atomic/schematics', '^1.0.0', 'devDependencies');
14
+ _utilities_1.addPackageToPackageJson(host, 'scoped-var', '^1.0.0', 'devDependencies');
17
15
  const installTaskId = context.addTask(new tasks_1.NodePackageInstallTask());
18
- // angular-host-css-variableのインストール
19
- const runSchematicTask = context.addTask(new tasks_1.RunSchematicTask('angular-host-css-variable', 'ng-add', { project: options.project }), [installTaskId]);
20
16
  // Set Up Angular Atomic Schematics
21
- context.addTask(new tasks_1.RunSchematicTask('setup-project', Object.assign({}, options)), [runSchematicTask]);
17
+ context.addTask(new tasks_1.RunSchematicTask('setup', Object.assign({}, options)), [installTaskId]);
22
18
  return host;
23
19
  };
24
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/ng-add/index.ts"],"names":[],"mappings":";;;AACA,4DAA4F;AAC5F,8CAA0F;AAE1F,mBAAwB,OAAY;IAClC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,gBAAgB,GAAG,6CAAgC,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QACjF,MAAM,wBAAwB,GAAG,gBAAgB,IAAI,UAAU,CAAC;QAEhE,IAAI,wBAAwB,KAAK,UAAU,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC5D;QAEH,cAAc;QACd,oCAAuB,CACtB,IAAI,EACJ,2BAA2B,EAC3B,uBAAuB,CAAC,wBAAwB,CAAC,EACjD,iBAAiB,CACjB,CAAC;QAEF,oCAAuB,CACtB,IAAI,EACJ,2BAA2B,EAC3B,uBAAuB,CAAC,wBAAwB,CAAC,EACjD,iBAAiB,CACjB,CAAC;QAEF,oCAAuB,CACtB,IAAI,EACJ,iCAAiC,EAC9B,uBAAuB,CAAC,wBAAwB,CAAC,EACpD,iBAAiB,CACjB,CAAC;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,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC5D;QAEH,oCAAuB,CAAC,IAAI,EAAE,uBAAuB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACpF,oCAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAEzE,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAEpE,mCAAmC;QACnC,OAAO,CAAC,OAAO,CAAC,IAAI,wBAAgB,CAAC,OAAO,oBAAM,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAA;QAE7E,OAAO,IAAI,CAAA;IACX,CAAC,CAAA;AACH,CAAC;AAnBD,4BAmBC;AAED,SAAgB,uBAAuB,CAAC,GAAW;IACjD,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtE,QAAQ,KAAK,EAAE;QACb,KAAK,IAAI,CAAC,CAAC,OAAO,WAAW,CAAC;QAC9B,KAAK,IAAI,CAAC,CAAC,OAAO,WAAW,CAAC;QAC9B,OAAO,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KACrE;AACH,CAAC;AAPD,0DAOC"}
@@ -14,14 +14,14 @@
14
14
  "componentsDir": {
15
15
  "description": "Setup components directory",
16
16
  "type": "string",
17
- "default": "src/app/_shared/components",
17
+ "default": "_shared/components",
18
18
  "x-prompt": "Where do you setup Angular Atomic Components?"
19
19
  },
20
20
  "stylesDir": {
21
21
  "description": "Setup styles directory",
22
22
  "type": "string",
23
23
  "default": "src/styles",
24
- "x-prompt": "Where do you setup Angular Atomic Styles?"
24
+ "x-prompt": "Where do you setup Angular Atomic Styles?\nIf you use Nx workspace you should input `apps/app/src/styles`"
25
25
 
26
26
  }
27
27
  },
@@ -1,26 +1,26 @@
1
1
  import { NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { Routes, RouterModule } from '@angular/router';
4
- import { TestPage } from './test.page';
4
+ import { ExamplePage } from './example.page';
5
5
 
6
6
  const routes: Routes = [
7
7
  {
8
8
  path: '',
9
- component: TestPage,
9
+ component: ExamplePage,
10
10
  // loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule)
11
11
  }
12
12
  ];
13
13
 
14
14
  @NgModule({
15
15
  declarations: [
16
- TestPage
16
+ ExamplePage
17
17
  ],
18
18
  imports: [
19
19
  CommonModule,
20
20
  RouterModule.forChild(routes)
21
21
  ],
22
22
  exports: [
23
- TestPage
23
+ ExamplePage
24
24
  ]
25
25
  })
26
- export class TestModule { }
26
+ export class ExampleModule { }
@@ -0,0 +1,6 @@
1
+ @use 'scoped-var/strict' as * with ($host:'example');
2
+ @use 'atomic/page' as *;
3
+
4
+ :host {
5
+ @include page($host);
6
+ }
@@ -0,0 +1,15 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'pages-example',
5
+ templateUrl: './example.page.html',
6
+ styleUrls: ['./example.page.scss']
7
+ })
8
+ export class ExamplePage implements OnInit {
9
+
10
+ constructor() { }
11
+
12
+ ngOnInit(): void {
13
+ }
14
+
15
+ }
package/src/page/index.js CHANGED
@@ -8,19 +8,21 @@ const strings_1 = require("@angular-devkit/core/src/utils/strings");
8
8
  const _utilities_1 = require("../_utilities");
9
9
  const workspace_1 = require("@schematics/angular/utility/workspace");
10
10
  exports.page = (options) => (host) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
- var _a, _b;
12
- (_a = options.path) !== null && _a !== void 0 ? _a : (options.path = yield workspace_1.createDefaultPath(host, options.project));
13
- (_b = options.type) !== null && _b !== void 0 ? _b : (options.type = 'page');
11
+ var _a;
12
+ options.type = 'page';
14
13
  options.name = resolveName(options.name);
15
- const { name, path, type, project, styleHeader } = options = Object.assign(Object.assign({}, options), parse_name_1.parseName(options.path, options.name));
14
+ options.prefix || (options.prefix = `${options.type}s`);
15
+ (_a = options.path) !== null && _a !== void 0 ? _a : (options.path = yield workspace_1.createDefaultPath(host, options.project));
16
+ const { name, path, type, project } = options = Object.assign(Object.assign({}, options), parse_name_1.parseName(options.path, options.name));
17
+ const componentExt = options.useTypeAsExtension ? type : 'component';
18
+ const scssPath = `${path}/${name}/${name}.${componentExt}.scss`;
16
19
  const pages = getPagesOptions(`${path}/${name}`);
17
- delete options['styleHeader'];
18
20
  return schematics_1.chain([
19
21
  schematics_1.schematic('pages', Object.assign(Object.assign({}, pages), { project })),
20
22
  addRouteIntoPagesModule(options, pages),
21
23
  schematics_1.schematic('pages', { name, path, project }),
22
- schematics_1.externalSchematic('@schematics/angular', 'component', Object.assign(Object.assign({}, options), { export: true })),
23
- // externalSchematic('@ng-atomic/host-variable', 'component', {...options, styleHeader: format(styleHeader, {name, type}), export: true}),
24
+ schematics_1.externalSchematic('@schematics/angular', 'component', Object.assign(Object.assign({}, options), { changeDetection: 'Default', export: true })),
25
+ schematics_1.schematic('style-header', Object.assign(Object.assign({}, options), { name, type, path: scssPath })),
24
26
  addRouteIntoPageModule(options, { path, name }),
25
27
  ]);
26
28
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/page/index.ts"],"names":[],"mappings":";;;;AAAA,2DAA6F;AAC7F,uEAAmE;AAEnE,oEAA6E;AAG7E,8CAAgD;AAChD,qEAA0E;AAK7D,QAAA,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAO,IAAU,EAAE,EAAE;;IACnE,MAAA,OAAO,CAAC,IAAI,oCAAZ,OAAO,CAAC,IAAI,GAAK,MAAM,6BAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAC;IAChE,MAAA,OAAO,CAAC,IAAI,oCAAZ,OAAO,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,EAAC,IAAI,EAAE,IAAI,EAAS,EAAE,IAAgB,EAAE,EAAE,CAAC,iCACrE,OAAO,KACV,iBAAiB,EAAE,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,YAAY,EACtD,KAAK,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,EAC9E,iBAAiB,EAAE,IAAI,KAAK,MAAM,IACjC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,IAAI,EAAU,EAAE,CAAC;;WAE/B,IAAI;kCACmB,mBAAS,CAAC,IAAI,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,yBAAyB,kBAAQ,CAAC,IAAI,CAAC;GACxG,CAAC;AAEJ,MAAM,cAAc,GAAG,CAAC,IAAI,EAAU,EAAE,CAAC;;;eAG1B,kBAAQ,CAAC,IAAI,CAAC;;GAE1B,CAAC"}
@@ -12,18 +12,26 @@ describe('Page Schematics', () => {
12
12
  });
13
13
 
14
14
  it('should create atomic component files', async () => {
15
- const options = {project: 'app', name: 'test'};
15
+ const options = {project: 'app', name: 'example'};
16
16
  const host = await runner.runSchematicAsync('page', options, tree).toPromise();
17
17
  expect(host.files.includes('/projects/app/src/app/pages/pages.module.ts')).toBeTruthy();
18
- expect(host.files.includes('/projects/app/src/app/pages/test/test.module.ts')).toBeTruthy();
19
- expect(host.files.includes('/projects/app/src/app/pages/test/test.page.html')).toBeTruthy();
20
- expect(host.files.includes('/projects/app/src/app/pages/test/test.page.scss')).toBeTruthy();
21
- expect(host.files.includes('/projects/app/src/app/pages/test/test.page.spec.ts')).toBeTruthy();
22
- expect(host.files.includes('/projects/app/src/app/pages/test/test.page.ts')).toBeTruthy();
18
+ expect(host.files.includes('/projects/app/src/app/pages/example/example.module.ts')).toBeTruthy();
19
+ expect(host.files.includes('/projects/app/src/app/pages/example/example.page.html')).toBeTruthy();
20
+ expect(host.files.includes('/projects/app/src/app/pages/example/example.page.scss')).toBeTruthy();
21
+ expect(host.files.includes('/projects/app/src/app/pages/example/example.page.spec.ts')).toBeTruthy();
22
+ expect(host.files.includes('/projects/app/src/app/pages/example/example.page.ts')).toBeTruthy();
23
23
 
24
- const input = host.read('/projects/app/src/app/pages/test/test.module.ts').toString('utf-8');
25
- const expected = readFileSync(join(__dirname, '_test/test.module.ts.expected')).toString('utf-8');
26
- expect(input.replace(/\s/g, '')).toEqual(expected.replace(/\s/g, ''));
24
+ const inputModuleTs = host.read('/projects/app/src/app/pages/example/example.module.ts').toString('utf-8');
25
+ const expectedModuleTs = readFileSync(join(__dirname, '_test/example.module.ts')).toString('utf-8');
26
+ expect(inputModuleTs.replace(/\s/g, '')).toEqual(expectedModuleTs.replace(/\s/g, ''));
27
+
28
+ const inputTs = host.read('/projects/app/src/app/pages/example/example.page.ts').toString('utf-8');
29
+ const expectedTs = readFileSync(join(__dirname, '_test/example.page.ts')).toString('utf-8');
30
+ expect(inputTs.replace(/\s/g, '')).toEqual(expectedTs.replace(/\s/g, ''));
31
+
32
+ const inputScss = host.read('/projects/app/src/app/pages/example/example.page.scss').toString('utf-8');
33
+ const expectedScss = readFileSync(join(__dirname, '_test/example.page.scss')).toString('utf-8');
34
+ expect(inputScss.replace(/\s/g, '')).toEqual(expectedScss.replace(/\s/g, ''));
27
35
 
28
36
  });
29
37
  });
@@ -1,7 +1,6 @@
1
- @import 'host-variable';
2
- @import 'atomic/component';
1
+ @use 'scoped-var' as *;
2
+ @use 'atomic/component' as *;
3
3
 
4
4
  @mixin atom($host) {
5
5
  @include component($host);
6
6
  }
7
-
@@ -1,12 +1,5 @@
1
- @import 'host-variable';
1
+ @use 'scoped-var' as *;
2
2
 
3
3
  @mixin component($host) {
4
4
  display: block;
5
-
6
- @include hvar(--cell, 8px);
7
-
8
- * {
9
- --cell: #{hvar(--cell)};
10
- }
11
5
  }
12
-
@@ -1,7 +1,6 @@
1
- @import 'host-variable';
2
- @import 'atomic/component';
1
+ @use 'scoped-var' as *;
2
+ @use 'atomic/component' as *;
3
3
 
4
4
  @mixin molecule($host) {
5
5
  @include component($host);
6
6
  }
7
-
@@ -1,7 +1,6 @@
1
- @import 'host-variable';
2
- @import 'atomic/component';
1
+ @use 'scoped-var' as *;
2
+ @use 'atomic/component' as *;
3
3
 
4
4
  @mixin organism($host) {
5
5
  @include component($host);
6
6
  }
7
-
@@ -1,7 +1,6 @@
1
- @import 'host-variable';
2
- @import 'atomic/component';
1
+ @use 'scoped-var' as *;
2
+ @use 'atomic/component' as *;
3
3
 
4
4
  @mixin page($host) {
5
5
  @include component($host);
6
6
  }
7
-
@@ -1,7 +1,6 @@
1
- @import 'host-variable';
2
- @import 'atomic/component';
1
+ @use 'scoped-var' as *;
2
+ @use 'atomic/component' as *;
3
3
 
4
4
  @mixin template($host) {
5
5
  @include component($host);
6
6
  }
7
-
@@ -14,12 +14,12 @@ describe('Setup Schematics', () => {
14
14
  const options = {project: 'app', name: 'pages'};
15
15
  const host = await runner.runSchematicAsync('setup', options, tree).toPromise();
16
16
  const angularJson = JSON.parse(host.read('/angular.json').toString('utf-8'));
17
- expect(get(angularJson, 'cli.defaultCollection')).toEqual('angular-atomic-schematics');
17
+ expect(get(angularJson, 'cli.defaultCollection')).toEqual('@ng-atomic/schematics');
18
18
  const schematicsJson = get(angularJson, 'projects.app.schematics');
19
19
 
20
20
  for (const type of ['atom', 'molecule', 'organism', 'template']) {
21
- expect(get(schematicsJson, `angular-atomic-schematics:${type}`))
22
- .toEqual({path: `src/app/_shared/components/${type}s`});
21
+ expect(get(schematicsJson, `@ng-atomic/schematics:${type}`))
22
+ .toEqual({path: `_shared/components/${type}s`});
23
23
  }
24
24
 
25
25
  const architectJson = get(angularJson, 'projects.app.architect');
@@ -31,7 +31,7 @@ describe('Setup Schematics', () => {
31
31
  }
32
32
 
33
33
  const tsconfigJson = JSON.parse(host.read('/tsconfig.json').toString('utf-8'));
34
- expect(get(tsconfigJson, 'compilerOptions.paths.@components')).toContain('src/app/_shared/components');
35
- expect(get(tsconfigJson, 'compilerOptions.paths.@components/*')).toContain('src/app/_shared/components/*');
34
+ expect(get(tsconfigJson, 'compilerOptions.paths.@components')).toContain('_shared/components');
35
+ expect(get(tsconfigJson, 'compilerOptions.paths.@components/*')).toContain('_shared/components/*');
36
36
  });
37
37
  });
@@ -0,0 +1,6 @@
1
+ @use 'scoped-var/strict' as * with ($host: 'example');
2
+ @use 'atomic/component' as *;
3
+
4
+ :host {
5
+ @include component($host);
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { Schema } from './schema';
3
+ declare const _default: (_options: Schema) => Rule;
4
+ export default _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const strings_1 = require("@angular-devkit/core/src/utils/strings");
5
+ const format = require("string-template");
6
+ const path_1 = require("path");
7
+ const save_file_1 = require("../_utilities/save-file");
8
+ const buildOptions = (options) => {
9
+ var _a, _b;
10
+ return (Object.assign(Object.assign({}, options), { name: (options === null || options === void 0 ? void 0 : options.name) || ((_a = path_1.basename(options.path, '.scss').split('.')) === null || _a === void 0 ? void 0 : _a[0]), type: (options === null || options === void 0 ? void 0 : options.type) || ((_b = path_1.basename(options.path, '.scss').split('.').reverse()) === null || _b === void 0 ? void 0 : _b[0]) }));
11
+ };
12
+ const buildStyle = ({ styleHeader, name, type }) => format(styleHeader, { name: strings_1.dasherize(name), type: type });
13
+ exports.default = (_options) => (host) => {
14
+ const _a = buildOptions(_options), { path } = _a, extra = tslib_1.__rest(_a, ["path"]);
15
+ return save_file_1.saveFile(host, path, (src) => `${buildStyle(extra)}${src}`);
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/style-header/index.ts"],"names":[],"mappings":";;;AACA,oEAAkE;AAClE,0CAA0C;AAC1C,+BAAgC;AAEhC,uDAAmD;AAEnD,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE;;IAAC,OAAA,iCAC7C,OAAO,KACV,IAAI,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,YAAI,eAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,0CAAG,CAAC,EAAC,EACtE,IAAI,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,YAAI,eAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,0CAAG,CAAC,EAAC,IAChF,CAAA;CAAA,CAAC;AAEH,MAAM,UAAU,GAAG,CAAC,EAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAgD,EAAU,EAAE,CACtG,MAAM,CAAC,WAAW,EAAE,EAAC,IAAI,EAAE,mBAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;AAE3D,kBAAe,CAAC,QAAgB,EAAQ,EAAE,CAAC,CAAC,IAAU,EAAE,EAAE;IACxD,MAAM,KAAmB,YAAY,CAAC,QAAQ,CAAC,EAAzC,EAAC,IAAI,OAAoC,EAA/B,KAAK,sBAAf,QAAgB,CAAyB,CAAC;IAChD,OAAO,oBAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AACrF,CAAC,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
2
+ import { readFileSync } from 'fs';
3
+ import * as path from 'path';
4
+ import { join } from 'path';
5
+ import { createWorkspace } from '../_testing';
6
+
7
+ const COLLECTION_PATH = path.join(__dirname, '../../collection.json');
8
+
9
+ describe('StyleHeader', () => {
10
+ const runner = new SchematicTestRunner('@ng-atomic/schematics', COLLECTION_PATH);
11
+ let tree: UnitTestTree;
12
+
13
+ beforeEach(async () => {
14
+ tree = await createWorkspace(runner, tree);
15
+ const options = {project: 'app', style: 'scss', name: 'example', skipImport: true };
16
+ tree = await runner.runExternalSchematicAsync('@schematics/angular', 'component', options, tree).toPromise();
17
+ });
18
+
19
+ describe('given all options', () => {
20
+ it('should be added style header', async () => {
21
+ const PATH = '/projects/app/src/app/example/example.component.scss';
22
+ const options = {path: PATH, name: 'example', type: 'component'};
23
+
24
+ await runner.runSchematicAsync('style-header', options, tree).toPromise();
25
+ const input = tree.read(PATH).toString('utf-8');
26
+ const expected = readFileSync(join(__dirname, '_test/example.scss')).toString();
27
+ expect(input.replace(/\s/g, '')).toEqual(expected.replace(/\s/g, ''));
28
+ });
29
+ });
30
+
31
+ describe('given only options.path', () => {
32
+ it('should be added style header', async () => {
33
+ const PATH = '/projects/app/src/app/example/example.component.scss';
34
+ const options = {path: PATH};
35
+
36
+ await runner.runSchematicAsync('style-header', options, tree).toPromise();
37
+ const input = tree.read(PATH).toString('utf-8');
38
+ const expected = readFileSync(join(__dirname, '_test/example.scss')).toString();
39
+ expect(input.replace(/\s/g, '')).toEqual(expected.replace(/\s/g, ''));
40
+ });
41
+ });
42
+
43
+ });
@@ -0,0 +1,6 @@
1
+ export interface Schema {
2
+ path: string;
3
+ name: string;
4
+ type: string;
5
+ styleHeader: string;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/style-header/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SchematicsAngularComponent",
4
+ "title": "Style Header Options Schema",
5
+ "type": "object",
6
+ "description": "Creates a new generic component definition in the given or default project.",
7
+ "properties": {
8
+ "path": {
9
+ "type": "string",
10
+ "format": "path",
11
+ "description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
12
+ "visible": false
13
+ },
14
+ "styleHeader": {
15
+ "type": "string",
16
+ "default": "@use 'scoped-var/strict' as * with ($host: '{name}');\n@use 'atomic/{type}' as *;\n:host {\n\t@include {type}($host);\n}\n",
17
+ "description": "scss header template. you can use template engine like `($host: '{name}.{type}'`. "
18
+ }
19
+ },
20
+ "required": ["path"]
21
+ }
22
+