@ng-atomic/schematics 1.5.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.
- package/package.json +3 -1
- package/src/_utilities/angular-config.js +1 -1
- package/src/_utilities/angular-config.js.map +1 -1
- package/src/atomic-component/_test/example.atom.scss +1 -1
- package/src/atomic-component/index.js +11 -20
- package/src/atomic-component/index.js.map +1 -1
- package/src/atomic-component/index.spec.ts +1 -1
- package/src/atomic-component/schema.json +1 -1
- package/src/ng-add/index.js +3 -3
- package/src/ng-add/index.js.map +1 -1
- package/src/ng-add/schema.json +2 -2
- package/src/page/_test/{test.module.ts.expected → example.module.ts} +5 -5
- package/src/page/_test/example.page.scss +6 -0
- package/src/page/_test/example.page.ts +15 -0
- package/src/page/index.js +9 -7
- package/src/page/index.js.map +1 -1
- package/src/page/index.spec.ts +17 -9
- package/src/setup/index.spec.ts +5 -5
- package/src/style-header/_test/example.scss +1 -1
- package/src/style-header/schema.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-atomic/schematics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"schematics": "./collection.json",
|
|
5
5
|
"ng-add": {
|
|
6
6
|
"save": "devDependencies"
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"typings": "src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@angular/core": "^11.2.0",
|
|
12
|
+
"@angular/common": "^11.2.0",
|
|
13
|
+
"@angular/router": "^11.2.0",
|
|
12
14
|
"string-template": "^1.0.0"
|
|
13
15
|
},
|
|
14
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 = '
|
|
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,
|
|
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,uBAAuB,CAAC;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"}
|
|
@@ -8,31 +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
|
|
12
|
-
|
|
13
|
-
options.path = path_1.join(yield workspace_1.createDefaultPath(host, options.project), (
|
|
14
|
-
const { name, path, type } = options = Object.assign(Object.assign({}, options), parse_name_1.parseName(options.path, options.name));
|
|
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
15
|
const componentExt = options.useTypeAsExtension ? type : 'component';
|
|
16
16
|
const scssPath = `${path}/${name}/${name}.${componentExt}.scss`;
|
|
17
17
|
return schematics_1.chain([
|
|
18
|
-
schematics_1.externalSchematic('@schematics/angular', 'module', { name, path, project
|
|
18
|
+
schematics_1.externalSchematic('@schematics/angular', 'module', { name, path, project }),
|
|
19
19
|
schematics_1.externalSchematic('@schematics/angular', 'component', Object.assign(Object.assign({}, options), { type: componentExt, export: true })),
|
|
20
|
-
schematics_1.schematic('style-header', Object.assign(Object.assign({}, options), { name, type, path: scssPath })),
|
|
21
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 })),
|
|
22
22
|
]);
|
|
23
23
|
});
|
|
24
|
-
exports.atom = (options) => exports.atomicComponent(
|
|
25
|
-
exports.molecule = (options) => exports.atomicComponent(
|
|
26
|
-
exports.organism = (options) => exports.atomicComponent(
|
|
27
|
-
exports.template = (options) => exports.atomicComponent(
|
|
28
|
-
exports.frame = (options) => exports.atomicComponent(
|
|
29
|
-
const buildOptions = (options, type) => (Object.assign(Object.assign({}, options), { type: options.type || type, prefix: options.prefix || `${options.type || type}s` }));
|
|
30
|
-
const addExportIntoIndexTs = ({ path, name }) => (tree) => {
|
|
31
|
-
const indexTsPath = path_1.join(path, 'index.ts');
|
|
32
|
-
tree.exists(indexTsPath) || tree.create(indexTsPath, '');
|
|
33
|
-
const lines = tree.read(indexTsPath).toString('utf-8').split('\n').filter(line => line.length);
|
|
34
|
-
const line = `export { ${strings.classify(name)}Module } from './${strings.dasherize(name)}';`;
|
|
35
|
-
tree.overwrite(indexTsPath, (lines.includes(line) ? lines : [...lines, line]).join('\n'));
|
|
36
|
-
return tree;
|
|
37
|
-
};
|
|
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' })));
|
|
38
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,2DAIoC;AACpC,kEAAkE;AAClE,uEAAmE;AACnE,qEAA0E;AAC1E,+BAA4B;AAGf,QAAA,eAAe,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAO,IAAU,EAAE,CAAmB,EAAE,EAAE;;IACnG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/atomic-component/index.ts"],"names":[],"mappings":";;;;AAAA,2DAIoC;AACpC,kEAAkE;AAClE,uEAAmE;AACnE,qEAA0E;AAC1E,+BAA4B;AAGf,QAAA,eAAe,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAO,IAAU,EAAE,CAAmB,EAAE,EAAE;;IACnG,OAAO,CAAC,MAAM,KAAd,OAAO,CAAC,MAAM,GAAK,GAAG,OAAO,CAAC,IAAI,GAAG,EAAC;IACtC,OAAO,CAAC,IAAI,GAAG,WAAI,CAAC,MAAM,6BAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,QAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,EAAE,CAAC,CAAC;IAEzF,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,mCAAO,OAAO,GAAK,sBAAS,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACvG,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,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,QAAA,KAAK,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,uBAAe,CAAC,iCAAK,OAAO,KAAE,IAAI,EAAE,OAAO,IAAE,CAAC,CAAC"}
|
|
@@ -80,7 +80,7 @@ describe('AtomicComponent Schematics', () => {
|
|
|
80
80
|
|
|
81
81
|
const inputScss = tree.read('/projects/app2/src/app/_shared/components/example/example.component.scss').toString('utf-8');
|
|
82
82
|
expect(inputScss.replace(/\s/g, '')).toEqual(`
|
|
83
|
-
@use 'scoped-var' as * with ($host: 'example');
|
|
83
|
+
@use 'scoped-var/strict' as * with ($host: 'example');
|
|
84
84
|
@use 'atomic/dialog' as *;
|
|
85
85
|
|
|
86
86
|
:host {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
"styleHeader": {
|
|
124
124
|
"type": "string",
|
|
125
|
-
"default": "@use 'scoped-var' as * with ($host: '{name}');\n@use 'atomic/{type}' as *;\n:host {\n\t@include {type}($host);\n}\n",
|
|
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
126
|
"description": "scss header template. you can use template engine like `($host: '{name}.{type}'`. "
|
|
127
127
|
},
|
|
128
128
|
"useTypeAsExtension": {
|
package/src/ng-add/index.js
CHANGED
|
@@ -10,11 +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
|
-
_utilities_1.addPackageToPackageJson(host, '@ng-atomic/schematics', '1.
|
|
14
|
-
_utilities_1.addPackageToPackageJson(host, 'scoped-var', '1.
|
|
13
|
+
_utilities_1.addPackageToPackageJson(host, '@ng-atomic/schematics', '^1.0.0', 'devDependencies');
|
|
14
|
+
_utilities_1.addPackageToPackageJson(host, 'scoped-var', '^1.0.0', 'devDependencies');
|
|
15
15
|
const installTaskId = context.addTask(new tasks_1.NodePackageInstallTask());
|
|
16
16
|
// Set Up Angular Atomic Schematics
|
|
17
|
-
context.addTask(new tasks_1.RunSchematicTask('setup
|
|
17
|
+
context.addTask(new tasks_1.RunSchematicTask('setup', Object.assign({}, options)), [installTaskId]);
|
|
18
18
|
return host;
|
|
19
19
|
};
|
|
20
20
|
}
|
package/src/ng-add/index.js.map
CHANGED
|
@@ -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,oCAAuB,CAAC,IAAI,EAAE,uBAAuB,EAAE,
|
|
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,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"}
|
package/src/ng-add/schema.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"componentsDir": {
|
|
15
15
|
"description": "Setup components directory",
|
|
16
16
|
"type": "string",
|
|
17
|
-
"default": "
|
|
18
|
-
"x-prompt": "Where do you setup Angular Atomic Components
|
|
17
|
+
"default": "_shared/components",
|
|
18
|
+
"x-prompt": "Where do you setup Angular Atomic Components?"
|
|
19
19
|
},
|
|
20
20
|
"stylesDir": {
|
|
21
21
|
"description": "Setup styles directory",
|
|
@@ -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 {
|
|
4
|
+
import { ExamplePage } from './example.page';
|
|
5
5
|
|
|
6
6
|
const routes: Routes = [
|
|
7
7
|
{
|
|
8
8
|
path: '',
|
|
9
|
-
component:
|
|
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
|
-
|
|
16
|
+
ExamplePage
|
|
17
17
|
],
|
|
18
18
|
imports: [
|
|
19
19
|
CommonModule,
|
|
20
20
|
RouterModule.forChild(routes)
|
|
21
21
|
],
|
|
22
22
|
exports: [
|
|
23
|
-
|
|
23
|
+
ExamplePage
|
|
24
24
|
]
|
|
25
25
|
})
|
|
26
|
-
export class
|
|
26
|
+
export class ExampleModule { }
|
|
@@ -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
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
});
|
package/src/page/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/page/index.ts"],"names":[],"mappings":";;;;AAAA,2DAA6F;AAC7F,uEAAmE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/page/index.ts"],"names":[],"mappings":";;;;AAAA,2DAA6F;AAC7F,uEAAmE;AACnE,oEAA6E;AAG7E,8CAAgD;AAChD,qEAA0E;AAK7D,QAAA,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAO,IAAU,EAAE,EAAE;;IACnE,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IACtB,OAAO,C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Ac,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"}
|
package/src/page/index.spec.ts
CHANGED
|
@@ -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: '
|
|
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/
|
|
19
|
-
expect(host.files.includes('/projects/app/src/app/pages/
|
|
20
|
-
expect(host.files.includes('/projects/app/src/app/pages/
|
|
21
|
-
expect(host.files.includes('/projects/app/src/app/pages/
|
|
22
|
-
expect(host.files.includes('/projects/app/src/app/pages/
|
|
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
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
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
|
});
|
package/src/setup/index.spec.ts
CHANGED
|
@@ -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('
|
|
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,
|
|
22
|
-
.toEqual({path: `
|
|
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('
|
|
35
|
-
expect(get(tsconfigJson, 'compilerOptions.paths.@components/*')).toContain('
|
|
34
|
+
expect(get(tsconfigJson, 'compilerOptions.paths.@components')).toContain('_shared/components');
|
|
35
|
+
expect(get(tsconfigJson, 'compilerOptions.paths.@components/*')).toContain('_shared/components/*');
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"styleHeader": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"default": "@use 'scoped-var' as * with ($host: '{name}');\n@use 'atomic/{type}' as *;\n:host {\n\t@include {type}($host);\n}\n",
|
|
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
17
|
"description": "scss header template. you can use template engine like `($host: '{name}.{type}'`. "
|
|
18
18
|
}
|
|
19
19
|
},
|