@ng-atomic/schematics 17.5.0 → 17.6.1
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/collection.json +31 -24
- package/index.js +399 -0
- package/index.js.map +7 -0
- package/lib/_utilities/index.js +188 -0
- package/lib/_utilities/index.js.map +7 -0
- package/lib/atomic-component/index.js +96 -0
- package/lib/atomic-component/index.js.map +7 -0
- package/lib/ng-add/index.js +126 -0
- package/lib/ng-add/index.js.map +7 -0
- package/lib/page/index.js +256 -0
- package/lib/page/index.js.map +7 -0
- package/lib/pages/index.js +39 -0
- package/lib/pages/index.js.map +7 -0
- package/lib/setup/index.js +109 -0
- package/lib/setup/index.js.map +7 -0
- package/lib/style-header/index.js +56 -0
- package/lib/style-header/index.js.map +7 -0
- package/package.json +3 -5
- package/src/_utilities/add-path-to-routes.d.ts +0 -2
- package/src/_utilities/add-path-to-routes.js +0 -34
- package/src/_utilities/add-path-to-routes.js.map +0 -1
- package/src/_utilities/angular-config.d.ts +0 -4
- package/src/_utilities/angular-config.js +0 -23
- package/src/_utilities/angular-config.js.map +0 -1
- package/src/_utilities/index.d.ts +0 -4
- package/src/_utilities/index.js +0 -8
- package/src/_utilities/index.js.map +0 -1
- package/src/_utilities/overwrite.d.ts +0 -2
- package/src/_utilities/overwrite.js +0 -13
- package/src/_utilities/overwrite.js.map +0 -1
- package/src/_utilities/package-config.d.ts +0 -12
- package/src/_utilities/package-config.js +0 -47
- package/src/_utilities/package-config.js.map +0 -1
- package/src/_utilities/save-file.d.ts +0 -2
- package/src/_utilities/save-file.js +0 -11
- package/src/_utilities/save-file.js.map +0 -1
- package/src/_utilities/ts-config.d.ts +0 -2
- package/src/_utilities/ts-config.js +0 -15
- package/src/_utilities/ts-config.js.map +0 -1
- package/src/atomic-component/_test/example.atom.scss +0 -6
- package/src/atomic-component/_test/example.atom.ts +0 -16
- package/src/atomic-component/index.d.ts +0 -10
- package/src/atomic-component/index.js +0 -53
- package/src/atomic-component/index.js.map +0 -1
- package/src/atomic-component/index.spec.ts +0 -187
- package/src/atomic-component/schema.d.ts +0 -24
- package/src/atomic-component/schema.js +0 -3
- package/src/atomic-component/schema.js.map +0 -1
- package/src/index.d.ts +0 -6
- package/src/index.js +0 -10
- package/src/index.js.map +0 -1
- package/src/ng-add/index.d.ts +0 -3
- package/src/ng-add/index.js +0 -31
- package/src/ng-add/index.js.map +0 -1
- package/src/page/_test/example.module.ts +0 -26
- package/src/page/_test/example.page.scss +0 -6
- package/src/page/_test/example.page.ts +0 -15
- package/src/page/index.d.ts +0 -3
- package/src/page/index.js +0 -71
- package/src/page/index.js.map +0 -1
- package/src/page/index.spec.ts +0 -37
- package/src/pages/index.d.ts +0 -3
- package/src/pages/index.js +0 -15
- package/src/pages/index.js.map +0 -1
- package/src/pages/index.spec.ts +0 -17
- package/src/pages/schema.d.ts +0 -7
- package/src/pages/schema.js +0 -3
- package/src/pages/schema.js.map +0 -1
- package/src/setup/index.d.ts +0 -2
- package/src/setup/index.js +0 -18
- package/src/setup/index.js.map +0 -1
- package/src/setup/index.spec.ts +0 -37
- package/src/style-header/_test/example.scss +0 -6
- package/src/style-header/index.d.ts +0 -4
- package/src/style-header/index.js +0 -18
- package/src/style-header/index.js.map +0 -1
- package/src/style-header/index.spec.ts +0 -43
- package/src/style-header/schema.d.ts +0 -6
- package/src/style-header/schema.js +0 -3
- package/src/style-header/schema.js.map +0 -1
- /package/{src → lib}/atomic-component/files/__name@dasherize__/__name@dasherize__.stories.ts.template +0 -0
- /package/{src → lib}/atomic-component/files/__name@dasherize__/index.ts.template +0 -0
- /package/{src → lib}/atomic-component/files/__name@dasherize__/ng-package.json.template +0 -0
- /package/{src → lib}/atomic-component/schema.json +0 -0
- /package/{src → lib}/ng-add/schema.json +0 -0
- /package/{src → lib}/page/files/__name@dasherize__/__name@dasherize__.routes.ts.template +0 -0
- /package/{src → lib}/pages/files/__name@dasherize__/__name@dasherize__.routes.ts.template +0 -0
- /package/{src → lib}/pages/schema.json +0 -0
- /package/{src → lib}/setup/files/atomic/_atom.scss +0 -0
- /package/{src → lib}/setup/files/atomic/_component.scss +0 -0
- /package/{src → lib}/setup/files/atomic/_molecule.scss +0 -0
- /package/{src → lib}/setup/files/atomic/_organism.scss +0 -0
- /package/{src → lib}/setup/files/atomic/_page.scss +0 -0
- /package/{src → lib}/setup/files/atomic/_template.scss +0 -0
- /package/{src → lib}/style-header/schema.json +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/index.ts
|
|
30
|
+
var utilities_exports = {};
|
|
31
|
+
__export(utilities_exports, {
|
|
32
|
+
addPackageToPackageJson: () => addPackageToPackageJson,
|
|
33
|
+
addPathToRoutes: () => addPathToRoutes,
|
|
34
|
+
addPathsToTsConfig: () => addPathsToTsConfig,
|
|
35
|
+
addSchematicsConfig: () => addSchematicsConfig,
|
|
36
|
+
addStyleIncludePath: () => addStyleIncludePath,
|
|
37
|
+
getDefaultPath: () => getDefaultPath,
|
|
38
|
+
getPackageVersionFromPackageJson: () => getPackageVersionFromPackageJson,
|
|
39
|
+
isNxContext: () => isNxContext,
|
|
40
|
+
setDefaultCollection: () => setDefaultCollection
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(utilities_exports);
|
|
43
|
+
|
|
44
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/add-path-to-routes.ts
|
|
45
|
+
var import_ast_utils = require("@nx/workspace/src/utils/ast-utils");
|
|
46
|
+
var import_typescript = __toESM(require("typescript"));
|
|
47
|
+
var isVariableDeclaration = (n) => n.kind === import_typescript.default.SyntaxKind.VariableDeclaration;
|
|
48
|
+
var isIdentifier = (n) => n.kind === import_typescript.default.SyntaxKind.Identifier;
|
|
49
|
+
var isArrayLiteralExpression = (n) => n.kind === import_typescript.default.SyntaxKind.ArrayLiteralExpression;
|
|
50
|
+
var matchText = (n, text) => n.getText() === text;
|
|
51
|
+
var hasMatchTextChild = (n, text) => {
|
|
52
|
+
return n.getChildren().findIndex((c) => isIdentifier(c) && matchText(c, text)) !== -1;
|
|
53
|
+
};
|
|
54
|
+
var isRoutesVariableDeclaration = (n) => isVariableDeclaration(n) && hasMatchTextChild(n, "routes");
|
|
55
|
+
var addPathToRoutes = ({ route, routesPath, removeOtherRoutes }) => (host) => {
|
|
56
|
+
const src = import_typescript.default.createSourceFile(
|
|
57
|
+
routesPath,
|
|
58
|
+
host.read(routesPath).toString("utf-8"),
|
|
59
|
+
import_typescript.default.ScriptTarget.Latest,
|
|
60
|
+
true
|
|
61
|
+
);
|
|
62
|
+
const nodes = (0, import_ast_utils.getSourceNodes)(src);
|
|
63
|
+
const routeNodes = nodes.filter(isRoutesVariableDeclaration).map((n) => {
|
|
64
|
+
return n.getChildren().filter(isArrayLiteralExpression).reverse()[0];
|
|
65
|
+
});
|
|
66
|
+
if (routeNodes.length === 1) {
|
|
67
|
+
const n = routeNodes[0];
|
|
68
|
+
const recorder = host.beginUpdate(routesPath);
|
|
69
|
+
const suffix = n.elements.length > 0 && !removeOtherRoutes ? "," : "";
|
|
70
|
+
recorder.insertRight(n.getStart() + 1, `${route}${suffix}`);
|
|
71
|
+
host.commitUpdate(recorder);
|
|
72
|
+
}
|
|
73
|
+
return host;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/angular-config.ts
|
|
77
|
+
var import_lodash = __toESM(require("lodash.get"));
|
|
78
|
+
var import_lodash2 = __toESM(require("lodash.set"));
|
|
79
|
+
|
|
80
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/overwrite.ts
|
|
81
|
+
var import_jsonc_parser = require("jsonc-parser");
|
|
82
|
+
function overwrite(host, file, callback) {
|
|
83
|
+
if (!host.exists(file))
|
|
84
|
+
return host;
|
|
85
|
+
const json = (0, import_jsonc_parser.parse)(host.read(file).toString("utf-8"));
|
|
86
|
+
host.overwrite(file, JSON.stringify(callback(json), null, 2));
|
|
87
|
+
return host;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/angular-config.ts
|
|
91
|
+
var PACKAGE_NAME = "@ng-atomic/schematics";
|
|
92
|
+
var addSchematicsConfig = ({ project, componentsDir }, type) => (host) => {
|
|
93
|
+
const query = `projects.${project}.schematics.${PACKAGE_NAME}:${type}`;
|
|
94
|
+
return overwrite(host, "angular.json", (json) => ((0, import_lodash2.default)(json, query, { "path": `${componentsDir}/${type}s` }), json));
|
|
95
|
+
};
|
|
96
|
+
var setDefaultCollection = () => (host) => {
|
|
97
|
+
return overwrite(host, "angular.json", (json) => ((0, import_lodash2.default)(json, `cli.defaultCollection`, PACKAGE_NAME), json));
|
|
98
|
+
};
|
|
99
|
+
var addStyleIncludePath = ({ project, stylesDir }) => (host) => {
|
|
100
|
+
const query = `projects.${project}.architect.build.options.stylePreprocessorOptions.includePaths`;
|
|
101
|
+
return overwrite(host, "angular.json", (json) => ((0, import_lodash2.default)(json, query, [...new Set((0, import_lodash.default)(json, query)).add(stylesDir)]), json));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/get-default-path.ts
|
|
105
|
+
var import_devkit2 = require("@nx/devkit");
|
|
106
|
+
var import_workspace = require("@schematics/angular/utility/workspace");
|
|
107
|
+
|
|
108
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/run-in-nx-context.ts
|
|
109
|
+
var import_devkit = require("@nx/devkit");
|
|
110
|
+
async function runInNxContext(tree, context, callback) {
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
(0, import_devkit.convertNxGenerator)((tree2) => resolve(callback(tree2)))({})(tree, context);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/get-default-path.ts
|
|
117
|
+
function isNxContext(context) {
|
|
118
|
+
return context.schematic.description.name.startsWith("@nrwl");
|
|
119
|
+
}
|
|
120
|
+
async function getDefaultPath(tree, context, project) {
|
|
121
|
+
if (tree.exists("nx.json")) {
|
|
122
|
+
const conf = await runInNxContext(tree, context, (nxTree) => {
|
|
123
|
+
return (0, import_devkit2.readProjectConfiguration)(nxTree, project);
|
|
124
|
+
});
|
|
125
|
+
return `${conf.sourceRoot}/${conf.projectType === "application" ? "app" : "lib"}`;
|
|
126
|
+
}
|
|
127
|
+
return (0, import_workspace.createDefaultPath)(tree, project);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/package-config.ts
|
|
131
|
+
function sortObjectByKeys(obj) {
|
|
132
|
+
return Object.keys(obj).sort().reduce((result, key) => (result[key] = obj[key]) && result, {});
|
|
133
|
+
}
|
|
134
|
+
function addPackageToPackageJson(host, pkg, version, dependencies = "dependencies") {
|
|
135
|
+
if (host.exists("package.json")) {
|
|
136
|
+
const sourceText = host.read("package.json").toString("utf-8");
|
|
137
|
+
const json = JSON.parse(sourceText);
|
|
138
|
+
if (!json[dependencies]) {
|
|
139
|
+
json[dependencies] = {};
|
|
140
|
+
}
|
|
141
|
+
if (!json[dependencies][pkg]) {
|
|
142
|
+
json[dependencies][pkg] = version;
|
|
143
|
+
json[dependencies] = sortObjectByKeys(json[dependencies]);
|
|
144
|
+
}
|
|
145
|
+
host.overwrite("package.json", JSON.stringify(json, null, 2));
|
|
146
|
+
}
|
|
147
|
+
return host;
|
|
148
|
+
}
|
|
149
|
+
function getPackageVersionFromPackageJson(tree, name) {
|
|
150
|
+
if (!tree.exists("package.json")) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const packageJson = JSON.parse(tree.read("package.json").toString("utf8"));
|
|
154
|
+
if (packageJson.dependencies && packageJson.dependencies[name]) {
|
|
155
|
+
return packageJson.dependencies[name];
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/ts-config.ts
|
|
161
|
+
var import_lodash3 = __toESM(require("lodash.set"));
|
|
162
|
+
var addPathsToTsConfig = ({ componentsDir }) => (host) => {
|
|
163
|
+
return overwrite(host, host.exists("tsconfig.base.json") ? "tsconfig.base.json" : "tsconfig.json", (json) => {
|
|
164
|
+
(0, import_lodash3.default)(json, `compilerOptions.paths.@components`, [componentsDir]);
|
|
165
|
+
(0, import_lodash3.default)(json, `compilerOptions.paths.@components/*`, [`${componentsDir}/*`]);
|
|
166
|
+
return json;
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
addPackageToPackageJson,
|
|
172
|
+
addPathToRoutes,
|
|
173
|
+
addPathsToTsConfig,
|
|
174
|
+
addSchematicsConfig,
|
|
175
|
+
addStyleIncludePath,
|
|
176
|
+
getDefaultPath,
|
|
177
|
+
getPackageVersionFromPackageJson,
|
|
178
|
+
isNxContext,
|
|
179
|
+
setDefaultCollection
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* @license
|
|
183
|
+
* Copyright Google LLC All Rights Reserved.
|
|
184
|
+
*
|
|
185
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
186
|
+
* found in the LICENSE file at https://angular.io/license
|
|
187
|
+
*/
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/index.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/add-path-to-routes.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/angular-config.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/overwrite.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/get-default-path.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/run-in-nx-context.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/package-config.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/ts-config.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './add-path-to-routes';\nexport * from './angular-config';\nexport * from './get-default-path';\nexport * from './package-config';\nexport * from './ts-config';\n", "import { Tree } from '@angular-devkit/schematics';\nimport { getSourceNodes } from '@nx/workspace/src/utils/ast-utils';\nimport ts from 'typescript';\n\nconst isVariableDeclaration = (n: ts.Node) =>\n n.kind === ts.SyntaxKind.VariableDeclaration;\nconst isIdentifier = (n: ts.Node) => n.kind === ts.SyntaxKind.Identifier;\nconst isArrayLiteralExpression = (n: ts.Node) =>\n n.kind === ts.SyntaxKind.ArrayLiteralExpression;\nconst matchText = (n: ts.Node, text: string) => n.getText() === text;\nconst hasMatchTextChild = (n: ts.Node, text: string) => {\n return (\n n.getChildren().findIndex((c) => isIdentifier(c) && matchText(c, text)) !==\n -1\n );\n};\nconst isRoutesVariableDeclaration = (n: ts.Node) =>\n isVariableDeclaration(n) && hasMatchTextChild(n, 'routes');\n\nexport const addPathToRoutes =\n ({ route, routesPath, removeOtherRoutes }: any) =>\n (host: Tree) => {\n const src = ts.createSourceFile(\n routesPath,\n host.read(routesPath)!.toString('utf-8'),\n ts.ScriptTarget.Latest,\n true\n );\n\n const nodes = getSourceNodes(src);\n const routeNodes = nodes\n .filter(isRoutesVariableDeclaration)\n .map((n: ts.Node) => {\n return n.getChildren().filter(isArrayLiteralExpression).reverse()[0];\n });\n\n if (routeNodes.length === 1) {\n const n = routeNodes[0] as ts.ArrayLiteralExpression;\n const recorder = host.beginUpdate(routesPath);\n const suffix = n.elements.length > 0 && !removeOtherRoutes ? ',' : '';\n recorder.insertRight(n.getStart() + 1, `${route}${suffix}`);\n host.commitUpdate(recorder);\n }\n\n return host;\n };\n", "import { Tree } from '@angular-devkit/schematics';\nimport get from 'lodash.get';\nimport set from 'lodash.set';\nimport { overwrite } from './overwrite';\n\nconst PACKAGE_NAME = '@ng-atomic/schematics';\n\nexport const addSchematicsConfig = ({project, componentsDir}: any, type: string) => (host: Tree): Tree => {\n\tconst query = `projects.${project}.schematics.${PACKAGE_NAME}:${type}`;\n\treturn overwrite(host, 'angular.json', json => (set(json, query, {'path': `${componentsDir}/${type}s`}), json));\n};\n\nexport const setDefaultCollection = () => (host: Tree) => {\n\treturn overwrite(host, 'angular.json', json => (set(json, `cli.defaultCollection`, PACKAGE_NAME), json));\n}\n\nexport const addStyleIncludePath = ({project, stylesDir}: any) => (host: Tree) => {\n\tconst query = `projects.${project}.architect.build.options.stylePreprocessorOptions.includePaths`;\n\treturn overwrite(host, 'angular.json', json => (set(json, query, [...new Set(get(json, query)).add(stylesDir)]), json));\n};\n", "\nimport { Tree } from '@angular-devkit/schematics';\nimport { parse } from \"jsonc-parser\";\n\nexport function overwrite(host: Tree, file: string, callback: (json: object) => object): Tree {\n\tif (!host.exists(file)) return host;\n\tconst json = parse(host.read(file)!.toString('utf-8'));\n\thost.overwrite(file, JSON.stringify(callback(json), null, 2));\n\treturn host;\n}\n", "import { SchematicContext } from \"@angular-devkit/schematics\";\nimport { Tree as NgTree } from \"@angular-devkit/schematics/src/tree/interface\";\nimport { readProjectConfiguration } from \"@nx/devkit\";\nimport { createDefaultPath } from \"@schematics/angular/utility/workspace\";\nimport { runInNxContext } from \"./run-in-nx-context\";\n\nexport function isNxContext(context: SchematicContext): boolean {\n return context.schematic.description.name.startsWith('@nrwl');\n}\n\nexport async function getDefaultPath(tree: NgTree, context: SchematicContext, project: string): Promise<string> {\n if (tree.exists('nx.json')) {\n\t\tconst conf = await runInNxContext(tree, context, (nxTree) => {\n\t\t\treturn readProjectConfiguration(nxTree, project);\n\t\t});\n return `${conf.sourceRoot}/${conf.projectType === 'application' ? 'app' : 'lib'}`;\n }\n return createDefaultPath(tree, project);\n}", "import { SchematicContext, Tree } from \"@angular-devkit/schematics\";\nimport { convertNxGenerator } from \"@nx/devkit\";\nimport { Tree as NxTree } from '@nx/devkit';\n\nexport async function runInNxContext<T>(tree: Tree, context: SchematicContext, callback: (tree: NxTree) => T | Promise<T>): Promise<T> {\n\treturn new Promise<T>((resolve) => {\n\t\tconvertNxGenerator((tree: NxTree) => resolve(callback(tree)))({})(tree, context);\n\t});\n}\n", "/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Tree} from '@angular-devkit/schematics';\n\n/**\n * Sorts the keys of the given object.\n * @returns A new object instance with sorted keys\n */\nfunction sortObjectByKeys(obj: object) {\n return Object.keys(obj).sort().reduce((result, key) => (result[key] = obj[key]) && result, {});\n}\n\n/** Adds a package to the package.json in the given host tree. */\nexport function addPackageToPackageJson(\n\thost: Tree, \n\tpkg: string, \n\tversion: string, \n\tdependencies: string = 'dependencies'\n): Tree {\n\n if (host.exists('package.json')) {\n const sourceText = host.read('package.json')!.toString('utf-8');\n const json = JSON.parse(sourceText);\n\n if (!json[dependencies]) {\n json[dependencies] = {};\n }\n\n if (!json[dependencies][pkg]) {\n json[dependencies][pkg] = version;\n json[dependencies] = sortObjectByKeys(json[dependencies]);\n }\n\n host.overwrite('package.json', JSON.stringify(json, null, 2));\n }\n\n return host;\n}\n\n/** Gets the version of the specified package by looking at the package.json in the given tree. */\nexport function getPackageVersionFromPackageJson(tree: Tree, name: string): string | null {\n if (!tree.exists('package.json')) {\n return null;\n }\n\n const packageJson = JSON.parse(tree.read('package.json')!.toString('utf8'));\n\n if (packageJson.dependencies && packageJson.dependencies[name]) {\n return packageJson.dependencies[name];\n }\n\n return null;\n}\n\n", "import { Tree } from '@angular-devkit/schematics';\nimport set from 'lodash.set';\nimport { overwrite } from './overwrite';\n\nexport const addPathsToTsConfig = ({componentsDir}: any) => (host: Tree) => {\n\treturn overwrite(host, host.exists('tsconfig.base.json') ? 'tsconfig.base.json' : 'tsconfig.json', json => {\n\t\tset(json, `compilerOptions.paths.@components`, [componentsDir]);\n\t\tset(json, `compilerOptions.paths.@components/*`, [`${componentsDir}/*`]);\n\t\treturn json;\n\t});\n};\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,uBAA+B;AAC/B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AI;AAAA,EACtC;AAEA,SAAO;AACT;;;ACzDA,IAAAC,iBAAgB;AAGT,IAAM,qBAAqB,CAAC,EAAC,cAAa,MAAW,CAAC,SAAe;AAC3E,SAAO,UAAU,MAAM,KAAK,OAAO,oBAAoB,IAAI,uBAAuB,iBAAiB,UAAQ;AAC1G,uBAAAC,SAAI,MAAM,qCAAqC,CAAC,aAAa,CAAC;AAC9D,uBAAAA,SAAI,MAAM,uCAAuC,CAAC,GAAG,aAAa,IAAI,CAAC;AACvE,WAAO;AAAA,EACR,CAAC;AACF;",
|
|
6
|
+
"names": ["ts", "import_lodash", "set", "get", "import_devkit", "tree", "import_lodash", "set"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// packages/@ng-atomic/schematics/src/lib/atomic-component/index.ts
|
|
30
|
+
var atomic_component_exports = {};
|
|
31
|
+
__export(atomic_component_exports, {
|
|
32
|
+
atom: () => atom,
|
|
33
|
+
atomicComponent: () => atomicComponent,
|
|
34
|
+
dialog: () => dialog,
|
|
35
|
+
frame: () => frame,
|
|
36
|
+
molecule: () => molecule,
|
|
37
|
+
organism: () => organism,
|
|
38
|
+
sheet: () => sheet,
|
|
39
|
+
template: () => template
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(atomic_component_exports);
|
|
42
|
+
var import_schematics = require("@angular-devkit/schematics");
|
|
43
|
+
var strings = __toESM(require("@angular-devkit/core/src/utils/strings"));
|
|
44
|
+
var import_parse_name = require("@schematics/angular/utility/parse-name");
|
|
45
|
+
var import_workspace = require("@schematics/angular/utility/workspace");
|
|
46
|
+
var import_path = require("path");
|
|
47
|
+
var import_lodash = require("lodash");
|
|
48
|
+
var atomicComponent = (options) => async (host, _) => {
|
|
49
|
+
options.prefix ||= `${options.type}s`;
|
|
50
|
+
options.path = (0, import_path.join)(await (0, import_workspace.createDefaultPath)(host, options.project), options?.path ?? "");
|
|
51
|
+
const { name, path, type, project, standalone } = options = { ...options, ...(0, import_parse_name.parseName)(options.path, options.name) };
|
|
52
|
+
const opt = (0, import_lodash.omit)(options, ["styleHeader", "useTypeAsExtension", "story", "ngPackage"]);
|
|
53
|
+
const { styleHeader, useTypeAsExtension } = options;
|
|
54
|
+
const componentExt = useTypeAsExtension ? type : "component";
|
|
55
|
+
const scssPath = `${path}/${name}/${name}.${componentExt}.scss`;
|
|
56
|
+
return (0, import_schematics.chain)([
|
|
57
|
+
options.standalone ? (0, import_schematics.noop)() : (0, import_schematics.externalSchematic)("@schematics/angular", "module", { name, path, project }),
|
|
58
|
+
(0, import_schematics.externalSchematic)("@schematics/angular", "component", { ...opt, type: componentExt, export: true }),
|
|
59
|
+
(0, import_schematics.mergeWith)((0, import_schematics.apply)(
|
|
60
|
+
(0, import_schematics.url)("./files"),
|
|
61
|
+
[
|
|
62
|
+
(0, import_schematics.applyTemplates)({ ...strings, name, type: type ?? "component", standalone }),
|
|
63
|
+
(0, import_schematics.move)(path),
|
|
64
|
+
(0, import_schematics.filter)((path2) => {
|
|
65
|
+
if (path2.endsWith("/index.ts"))
|
|
66
|
+
return true;
|
|
67
|
+
if (options.ngPackage && path2.endsWith("/ng-package.json"))
|
|
68
|
+
return true;
|
|
69
|
+
if (options.story && path2.endsWith(".stories.ts"))
|
|
70
|
+
return true;
|
|
71
|
+
return false;
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
)),
|
|
75
|
+
(0, import_schematics.schematic)("style-header", { ...options, styleHeader, name, type, path: scssPath })
|
|
76
|
+
]);
|
|
77
|
+
};
|
|
78
|
+
var atom = (options) => atomicComponent({ ...options, type: "atom" });
|
|
79
|
+
var molecule = (options) => atomicComponent({ ...options, type: "molecule" });
|
|
80
|
+
var organism = (options) => atomicComponent({ ...options, type: "organism" });
|
|
81
|
+
var template = (options) => atomicComponent({ ...options, type: "template" });
|
|
82
|
+
var frame = (options) => atomicComponent({ ...options, type: "frame" });
|
|
83
|
+
var sheet = (options) => atomicComponent({ ...options, type: "sheet" });
|
|
84
|
+
var dialog = (options) => atomicComponent({ ...options, type: "dialog" });
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
atom,
|
|
88
|
+
atomicComponent,
|
|
89
|
+
dialog,
|
|
90
|
+
frame,
|
|
91
|
+
molecule,
|
|
92
|
+
organism,
|
|
93
|
+
sheet,
|
|
94
|
+
template
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../packages/@ng-atomic/schematics/src/lib/atomic-component/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { \n\tRule, Tree, SchematicContext, apply, chain,\n\texternalSchematic, schematic,\n\turl, applyTemplates, mergeWith, move, noop,\n\ttemplate as _template,\n\tfilter\n} from '@angular-devkit/schematics';\nimport * as strings from '@angular-devkit/core/src/utils/strings';\nimport { parseName } from '@schematics/angular/utility/parse-name';\nimport { createDefaultPath } from '@schematics/angular/utility/workspace';\nimport { join } from 'path';\nimport { Schema } from './schema';\nimport { omit } from 'lodash';\n\nexport const atomicComponent = (options: Schema): Rule => async (host: Tree, _: SchematicContext) => {\n\toptions.prefix ||= `${options.type}s`;\n\toptions.path = join(await createDefaultPath(host, options.project), options?.path ?? '');\n\n\tconst { name, path, type, project, standalone } = options = {...options, ...parseName(options.path, options.name)};\n\tconst opt = omit(options, ['styleHeader', 'useTypeAsExtension', 'story', 'ngPackage']);\n\tconst { styleHeader, useTypeAsExtension } = options;\n\tconst componentExt = useTypeAsExtension ? type : 'component';\n\tconst scssPath = `${path}/${name}/${name}.${componentExt}.scss`;\n\n\treturn chain([\n\t\toptions.standalone ? noop() : externalSchematic('@schematics/angular', 'module', {name, path, project}),\n\t\texternalSchematic('@schematics/angular', 'component', {...opt, type: componentExt, export: true}),\n\t\tmergeWith(apply(\n\t\t\turl('./files'),\n\t\t\t[\n\t\t\t\tapplyTemplates({...strings, name, type: type ?? 'component', standalone}),\n\t\t\t\tmove(path),\n\t\t\t\tfilter(path => {\n\t\t\t\t\tif (path.endsWith('/index.ts')) return true;\n\t\t\t\t\tif (options.ngPackage && path.endsWith('/ng-package.json')) return true;\n\t\t\t\t\tif (options.story && path.endsWith('.stories.ts')) return true;\n\t\t\t\t\treturn false\n\t\t\t\t}),\n\t\t\t],\n\t\t)), \n\t\tschematic('style-header', {...options, styleHeader, name, type, path: scssPath}),\n\t]);\n};\n\nexport const atom = (options: Schema): Rule => atomicComponent(({...options, type: 'atom'}));\nexport const molecule = (options: Schema): Rule => atomicComponent(({...options, type: 'molecule'}));\nexport const organism = (options: Schema): Rule => atomicComponent(({...options, type: 'organism'}));\nexport const template = (options: Schema): Rule => atomicComponent(({...options, type: 'template'}));\nexport const frame = (options: Schema): Rule => atomicComponent(({...options, type: 'frame'}));\nexport const sheet = (options: Schema): Rule => atomicComponent(({...options, type: 'sheet'}));\nexport const dialog = (options: Schema): Rule => atomicComponent(({...options, type: 'dialog'}));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMO;AACP,cAAyB;AACzB,wBAA0B;AAC1B,uBAAkC;AAClC,kBAAqB;AAErB,oBAAqB;AAEd,IAAM,kBAAkB,CAAC,YAA0B,OAAO,MAAY,MAAwB;AACpG,UAAQ,WAAW,GAAG,QAAQ,IAAI;AAClC,UAAQ,WAAO,kBAAK,UAAM,oCAAkB,MAAM,QAAQ,OAAO,GAAG,SAAS,QAAQ,EAAE;AAEvF,QAAM,EAAE,MAAM,MAAM,MAAM,SAAS,WAAW,IAAI,UAAU,EAAC,GAAG,SAAS,OAAG,6BAAU,QAAQ,MAAM,QAAQ,IAAI,EAAC;AACjH,QAAM,UAAM,oBAAK,SAAS,CAAC,eAAe,sBAAsB,SAAS,WAAW,CAAC;AACrF,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAC5C,QAAM,eAAe,qBAAqB,OAAO;AACjD,QAAM,WAAW,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,YAAY;AAExD,aAAO,yBAAM;AAAA,IACZ,QAAQ,iBAAa,wBAAK,QAAI,qCAAkB,uBAAuB,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
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// packages/@ng-atomic/schematics/src/lib/ng-add/index.ts
|
|
30
|
+
var ng_add_exports = {};
|
|
31
|
+
__export(ng_add_exports, {
|
|
32
|
+
default: () => ng_add_default,
|
|
33
|
+
getCustomWebpackVersion: () => getCustomWebpackVersion
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(ng_add_exports);
|
|
36
|
+
var import_tasks = require("@angular-devkit/schematics/tasks");
|
|
37
|
+
|
|
38
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/add-path-to-routes.ts
|
|
39
|
+
var import_ast_utils = require("@nx/workspace/src/utils/ast-utils");
|
|
40
|
+
var import_typescript = __toESM(require("typescript"));
|
|
41
|
+
|
|
42
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/angular-config.ts
|
|
43
|
+
var import_lodash = __toESM(require("lodash.get"));
|
|
44
|
+
var import_lodash2 = __toESM(require("lodash.set"));
|
|
45
|
+
|
|
46
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/overwrite.ts
|
|
47
|
+
var import_jsonc_parser = require("jsonc-parser");
|
|
48
|
+
|
|
49
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/get-default-path.ts
|
|
50
|
+
var import_devkit2 = require("@nx/devkit");
|
|
51
|
+
var import_workspace = require("@schematics/angular/utility/workspace");
|
|
52
|
+
|
|
53
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/run-in-nx-context.ts
|
|
54
|
+
var import_devkit = require("@nx/devkit");
|
|
55
|
+
|
|
56
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/package-config.ts
|
|
57
|
+
function sortObjectByKeys(obj) {
|
|
58
|
+
return Object.keys(obj).sort().reduce((result, key) => (result[key] = obj[key]) && result, {});
|
|
59
|
+
}
|
|
60
|
+
function addPackageToPackageJson(host, pkg, version, dependencies = "dependencies") {
|
|
61
|
+
if (host.exists("package.json")) {
|
|
62
|
+
const sourceText = host.read("package.json").toString("utf-8");
|
|
63
|
+
const json = JSON.parse(sourceText);
|
|
64
|
+
if (!json[dependencies]) {
|
|
65
|
+
json[dependencies] = {};
|
|
66
|
+
}
|
|
67
|
+
if (!json[dependencies][pkg]) {
|
|
68
|
+
json[dependencies][pkg] = version;
|
|
69
|
+
json[dependencies] = sortObjectByKeys(json[dependencies]);
|
|
70
|
+
}
|
|
71
|
+
host.overwrite("package.json", JSON.stringify(json, null, 2));
|
|
72
|
+
}
|
|
73
|
+
return host;
|
|
74
|
+
}
|
|
75
|
+
function getPackageVersionFromPackageJson(tree, name) {
|
|
76
|
+
if (!tree.exists("package.json")) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const packageJson = JSON.parse(tree.read("package.json").toString("utf8"));
|
|
80
|
+
if (packageJson.dependencies && packageJson.dependencies[name]) {
|
|
81
|
+
return packageJson.dependencies[name];
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// packages/@ng-atomic/schematics/src/lib/_utilities/ts-config.ts
|
|
87
|
+
var import_lodash3 = __toESM(require("lodash.set"));
|
|
88
|
+
|
|
89
|
+
// packages/@ng-atomic/schematics/src/lib/ng-add/index.ts
|
|
90
|
+
function ng_add_default(options) {
|
|
91
|
+
return (host, context) => {
|
|
92
|
+
const ngCoreVersionTag = getPackageVersionFromPackageJson(host, "@angular/core");
|
|
93
|
+
const angularDependencyVersion = ngCoreVersionTag || `0.0.0-NG`;
|
|
94
|
+
if (angularDependencyVersion === "0.0.0-NG") {
|
|
95
|
+
throw new Error("@angular/core version is not supported.");
|
|
96
|
+
}
|
|
97
|
+
addPackageToPackageJson(host, "@ng-atomic/schematics", "^1.0.0", "devDependencies");
|
|
98
|
+
addPackageToPackageJson(host, "scoped-var", "^1.0.0", "devDependencies");
|
|
99
|
+
const installTaskId = context.addTask(new import_tasks.NodePackageInstallTask());
|
|
100
|
+
context.addTask(new import_tasks.RunSchematicTask("setup", { ...options }), [installTaskId]);
|
|
101
|
+
return host;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function getCustomWebpackVersion(ver) {
|
|
105
|
+
const [major, minor, patch] = ver.replace(/(\^|\~)/, "").split(".");
|
|
106
|
+
switch (major) {
|
|
107
|
+
case "10":
|
|
108
|
+
return "^0.1000.0";
|
|
109
|
+
case "11":
|
|
110
|
+
return "^0.1100.0";
|
|
111
|
+
default:
|
|
112
|
+
throw new Error("@angular/core version is not supported.");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
getCustomWebpackVersion
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* @license
|
|
121
|
+
* Copyright Google LLC All Rights Reserved.
|
|
122
|
+
*
|
|
123
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
124
|
+
* found in the LICENSE file at https://angular.io/license
|
|
125
|
+
*/
|
|
126
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../packages/@ng-atomic/schematics/src/lib/ng-add/index.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/add-path-to-routes.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/angular-config.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/overwrite.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/get-default-path.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/run-in-nx-context.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/package-config.ts", "../../../../../../packages/@ng-atomic/schematics/src/lib/_utilities/ts-config.ts"],
|
|
4
|
+
"sourcesContent": ["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';\nimport { addPackageToPackageJson, getPackageVersionFromPackageJson } from '../_utilities';\n\nexport default function(options: any): Rule {\n return (host: Tree, context: SchematicContext) => {\n const ngCoreVersionTag = getPackageVersionFromPackageJson(host, '@angular/core');\n const angularDependencyVersion = ngCoreVersionTag || `0.0.0-NG`;\n\n if (angularDependencyVersion === '0.0.0-NG') {\n throw new Error('@angular/core version is not supported.');\n }\n\n\t\taddPackageToPackageJson(host, '@ng-atomic/schematics', '^1.0.0', 'devDependencies');\n\t\taddPackageToPackageJson(host, 'scoped-var', '^1.0.0', 'devDependencies');\n\n\t\tconst installTaskId = context.addTask(new NodePackageInstallTask());\n\t\t\n\t\t// Set Up Angular Atomic Schematics\n\t\tcontext.addTask(new RunSchematicTask('setup', {...options}), [installTaskId])\n\n\t\treturn host\n }\n}\n\nexport function getCustomWebpackVersion(ver: string): string {\n const [major, minor, patch] = (ver.replace(/(\\^|\\~)/, '')).split('.');\n switch (major) {\n case '10': return '^0.1000.0';\n case '11': return '^0.1100.0';\n default: throw new Error('@angular/core version is not supported.');\n }\n}", "import { Tree } from '@angular-devkit/schematics';\nimport { getSourceNodes } from '@nx/workspace/src/utils/ast-utils';\nimport ts from 'typescript';\n\nconst isVariableDeclaration = (n: ts.Node) =>\n n.kind === ts.SyntaxKind.VariableDeclaration;\nconst isIdentifier = (n: ts.Node) => n.kind === ts.SyntaxKind.Identifier;\nconst isArrayLiteralExpression = (n: ts.Node) =>\n n.kind === ts.SyntaxKind.ArrayLiteralExpression;\nconst matchText = (n: ts.Node, text: string) => n.getText() === text;\nconst hasMatchTextChild = (n: ts.Node, text: string) => {\n return (\n n.getChildren().findIndex((c) => isIdentifier(c) && matchText(c, text)) !==\n -1\n );\n};\nconst isRoutesVariableDeclaration = (n: ts.Node) =>\n isVariableDeclaration(n) && hasMatchTextChild(n, 'routes');\n\nexport const addPathToRoutes =\n ({ route, routesPath, removeOtherRoutes }: any) =>\n (host: Tree) => {\n const src = ts.createSourceFile(\n routesPath,\n host.read(routesPath)!.toString('utf-8'),\n ts.ScriptTarget.Latest,\n true\n );\n\n const nodes = getSourceNodes(src);\n const routeNodes = nodes\n .filter(isRoutesVariableDeclaration)\n .map((n: ts.Node) => {\n return n.getChildren().filter(isArrayLiteralExpression).reverse()[0];\n });\n\n if (routeNodes.length === 1) {\n const n = routeNodes[0] as ts.ArrayLiteralExpression;\n const recorder = host.beginUpdate(routesPath);\n const suffix = n.elements.length > 0 && !removeOtherRoutes ? ',' : '';\n recorder.insertRight(n.getStart() + 1, `${route}${suffix}`);\n host.commitUpdate(recorder);\n }\n\n return host;\n };\n", "import { Tree } from '@angular-devkit/schematics';\nimport get from 'lodash.get';\nimport set from 'lodash.set';\nimport { overwrite } from './overwrite';\n\nconst PACKAGE_NAME = '@ng-atomic/schematics';\n\nexport const addSchematicsConfig = ({project, componentsDir}: any, type: string) => (host: Tree): Tree => {\n\tconst query = `projects.${project}.schematics.${PACKAGE_NAME}:${type}`;\n\treturn overwrite(host, 'angular.json', json => (set(json, query, {'path': `${componentsDir}/${type}s`}), json));\n};\n\nexport const setDefaultCollection = () => (host: Tree) => {\n\treturn overwrite(host, 'angular.json', json => (set(json, `cli.defaultCollection`, PACKAGE_NAME), json));\n}\n\nexport const addStyleIncludePath = ({project, stylesDir}: any) => (host: Tree) => {\n\tconst query = `projects.${project}.architect.build.options.stylePreprocessorOptions.includePaths`;\n\treturn overwrite(host, 'angular.json', json => (set(json, query, [...new Set(get(json, query)).add(stylesDir)]), json));\n};\n", "\nimport { Tree } from '@angular-devkit/schematics';\nimport { parse } from \"jsonc-parser\";\n\nexport function overwrite(host: Tree, file: string, callback: (json: object) => object): Tree {\n\tif (!host.exists(file)) return host;\n\tconst json = parse(host.read(file)!.toString('utf-8'));\n\thost.overwrite(file, JSON.stringify(callback(json), null, 2));\n\treturn host;\n}\n", "import { SchematicContext } from \"@angular-devkit/schematics\";\nimport { Tree as NgTree } from \"@angular-devkit/schematics/src/tree/interface\";\nimport { readProjectConfiguration } from \"@nx/devkit\";\nimport { createDefaultPath } from \"@schematics/angular/utility/workspace\";\nimport { runInNxContext } from \"./run-in-nx-context\";\n\nexport function isNxContext(context: SchematicContext): boolean {\n return context.schematic.description.name.startsWith('@nrwl');\n}\n\nexport async function getDefaultPath(tree: NgTree, context: SchematicContext, project: string): Promise<string> {\n if (tree.exists('nx.json')) {\n\t\tconst conf = await runInNxContext(tree, context, (nxTree) => {\n\t\t\treturn readProjectConfiguration(nxTree, project);\n\t\t});\n return `${conf.sourceRoot}/${conf.projectType === 'application' ? 'app' : 'lib'}`;\n }\n return createDefaultPath(tree, project);\n}", "import { SchematicContext, Tree } from \"@angular-devkit/schematics\";\nimport { convertNxGenerator } from \"@nx/devkit\";\nimport { Tree as NxTree } from '@nx/devkit';\n\nexport async function runInNxContext<T>(tree: Tree, context: SchematicContext, callback: (tree: NxTree) => T | Promise<T>): Promise<T> {\n\treturn new Promise<T>((resolve) => {\n\t\tconvertNxGenerator((tree: NxTree) => resolve(callback(tree)))({})(tree, context);\n\t});\n}\n", "/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Tree} from '@angular-devkit/schematics';\n\n/**\n * Sorts the keys of the given object.\n * @returns A new object instance with sorted keys\n */\nfunction sortObjectByKeys(obj: object) {\n return Object.keys(obj).sort().reduce((result, key) => (result[key] = obj[key]) && result, {});\n}\n\n/** Adds a package to the package.json in the given host tree. */\nexport function addPackageToPackageJson(\n\thost: Tree, \n\tpkg: string, \n\tversion: string, \n\tdependencies: string = 'dependencies'\n): Tree {\n\n if (host.exists('package.json')) {\n const sourceText = host.read('package.json')!.toString('utf-8');\n const json = JSON.parse(sourceText);\n\n if (!json[dependencies]) {\n json[dependencies] = {};\n }\n\n if (!json[dependencies][pkg]) {\n json[dependencies][pkg] = version;\n json[dependencies] = sortObjectByKeys(json[dependencies]);\n }\n\n host.overwrite('package.json', JSON.stringify(json, null, 2));\n }\n\n return host;\n}\n\n/** Gets the version of the specified package by looking at the package.json in the given tree. */\nexport function getPackageVersionFromPackageJson(tree: Tree, name: string): string | null {\n if (!tree.exists('package.json')) {\n return null;\n }\n\n const packageJson = JSON.parse(tree.read('package.json')!.toString('utf8'));\n\n if (packageJson.dependencies && packageJson.dependencies[name]) {\n return packageJson.dependencies[name];\n }\n\n return null;\n}\n\n", "import { Tree } from '@angular-devkit/schematics';\nimport set from 'lodash.set';\nimport { overwrite } from './overwrite';\n\nexport const addPathsToTsConfig = ({componentsDir}: any) => (host: Tree) => {\n\treturn overwrite(host, host.exists('tsconfig.base.json') ? 'tsconfig.base.json' : 'tsconfig.json', json => {\n\t\tset(json, `compilerOptions.paths.@components`, [componentsDir]);\n\t\tset(json, `compilerOptions.paths.@components/*`, [`${componentsDir}/*`]);\n\t\treturn json;\n\t});\n};\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAyD;;;ACAzD,uBAA+B;AAC/B,wBAAe;;;ACDf,oBAAgB;AAChB,IAAAA,iBAAgB;;;ACAhB,0BAAsB;;;ACAtB,IAAAC,iBAAyC;AACzC,uBAAkC;;;ACFlC,oBAAmC;;;ACanC,SAAS,iBAAiB,KAAa;AACrC,SAAO,OAAO,KAAK,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,SAAS,OAAO,GAAG,IAAI,IAAI,GAAG,MAAM,QAAQ,CAAC,CAAC;AAC/F;AAGO,SAAS,wBACf,MACA,KACA,SACA,eAAuB,gBAChB;AAEN,MAAI,KAAK,OAAO,cAAc,GAAG;AAC/B,UAAM,aAAa,KAAK,KAAK,cAAc,EAAG,SAAS,OAAO;AAC9D,UAAM,OAAO,KAAK,MAAM,UAAU;AAElC,QAAI,CAAC,KAAK,YAAY,GAAG;AACvB,WAAK,YAAY,IAAI,CAAC;AAAA,IACxB;AAEA,QAAI,CAAC,KAAK,YAAY,EAAE,GAAG,GAAG;AAC5B,WAAK,YAAY,EAAE,GAAG,IAAI;AAC1B,WAAK,YAAY,IAAI,iBAAiB,KAAK,YAAY,CAAC;AAAA,IAC1D;AAEA,SAAK,UAAU,gBAAgB,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,EAC9D;AAEA,SAAO;AACT;AAGO,SAAS,iCAAiC,MAAY,MAA6B;AACxF,MA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