@abelfubu/schematics 0.0.3 → 0.1.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/package.json +5 -3
- package/src/feature/feature.js +4 -4
- package/src/feature/feature.js.map +1 -1
- package/src/feature/files/__fileName__.component.ts.template +2 -1
- package/src/feature/files/__fileName__.facade.spec.ts.template +24 -0
- package/src/feature/files/__fileName__.store.spec.ts.template +6 -8
- package/src/feature/schema.d.ts +1 -1
- package/src/feature/schema.json +5 -4
- package/src/ng-add/compat.d.ts +1 -1
- package/src/ng-add/index.d.ts +2 -2
- package/src/ng-add/index.js +44 -48
- package/src/ng-add/index.js.map +1 -1
- package/src/ng-add/schema.d.ts +5 -0
- package/src/ng-add/schema.json +14 -1
- package/src/utils/npm-latest-version.util.d.ts +6 -0
- package/src/utils/npm-latest-version.util.js +23 -0
- package/src/utils/npm-latest-version.util.js.map +1 -0
- package/src/utils/update-app-config.util.d.ts +9 -0
- package/src/utils/update-app-config.util.js +53 -0
- package/src/utils/update-app-config.util.js.map +1 -0
- package/src/utils/with-packages.util.d.ts +9 -0
- package/src/utils/with-packages.util.js +16 -0
- package/src/utils/with-packages.util.js.map +1 -0
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@abelfubu/schematics",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.1.1",
|
4
4
|
"type": "commonjs",
|
5
5
|
"main": "./src/index.js",
|
6
6
|
"types": "./src/index.d.ts",
|
7
7
|
"dependencies": {
|
8
8
|
"@nx/devkit": "21.0.3",
|
9
|
-
"
|
9
|
+
"nx": "21.0.3",
|
10
|
+
"tslib": "^2.3.0",
|
11
|
+
"ts-morph": "25.0.1"
|
10
12
|
},
|
11
13
|
"publishConfig": {
|
12
14
|
"access": "public"
|
@@ -17,4 +19,4 @@
|
|
17
19
|
},
|
18
20
|
"generators": "./generators.json",
|
19
21
|
"schematics": "./generators.json"
|
20
|
-
}
|
22
|
+
}
|
package/src/feature/feature.js
CHANGED
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.featureGenerator = featureGenerator;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
6
|
-
const
|
6
|
+
const node_path_1 = require("node:path");
|
7
7
|
function featureGenerator(tree, options) {
|
8
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
9
|
-
const
|
10
|
-
const { className, fileName, propertyName } = (0, devkit_1.names)(
|
11
|
-
(0, devkit_1.generateFiles)(tree,
|
9
|
+
const path = options.path.replace(/\\/g, '/');
|
10
|
+
const { className, fileName, propertyName } = (0, devkit_1.names)(path.split('/').pop() || path);
|
11
|
+
(0, devkit_1.generateFiles)(tree, (0, node_path_1.join)(__dirname, 'files'), path, {
|
12
12
|
fileName,
|
13
13
|
className,
|
14
14
|
propertyName,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/feature/feature.ts"],"names":[],"mappings":";;AAIA,4CAkBC;;AAtBD,uCAAqE;AACrE,
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/feature/feature.ts"],"names":[],"mappings":";;AAIA,4CAkBC;;AAtBD,uCAAqE;AACrE,yCAAiC;AAGjC,SAAsB,gBAAgB,CACpC,IAAU,EACV,OAA+B;;QAE/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE9C,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAA,cAAK,EACjD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAC9B,CAAC;QAEF,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE;YAClD,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}
|
@@ -3,10 +3,11 @@ import { <%= className %>Store } from './<%= fileName %>.store';
|
|
3
3
|
|
4
4
|
@Component({
|
5
5
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
6
|
+
host: { class: 'flex bg-gray-100 min-h-screen items-center justify-center' },
|
6
7
|
imports: [],
|
7
8
|
providers: [<%= className %>Store],
|
8
9
|
selector: '<%= prefix %>-<%= fileName %>',
|
9
|
-
template: `<h1>{{ store.name() }} works!!</h1>`,
|
10
|
+
template: `<h1 class="text-7xl">{{ store.name() }} works!!</h1>`,
|
10
11
|
})
|
11
12
|
export class <%= className %>Component implements OnInit {
|
12
13
|
protected readonly store = inject(<%= className %>Store);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { <%= className %>Facade } from './<%= fileName %>.facade';
|
4
|
+
|
5
|
+
describe(<%= className %>Facade.name, () => {
|
6
|
+
afterEach(() => jest.clearAllMocks());
|
7
|
+
|
8
|
+
function setup() {
|
9
|
+
TestBed.configureTestingModule({});
|
10
|
+
|
11
|
+
return {
|
12
|
+
facade: TestBed.inject(<%= className %>Facade),
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
it('should get', (done) => {
|
17
|
+
const { facade } = setup();
|
18
|
+
|
19
|
+
facade.get().subscribe((vale) => {
|
20
|
+
expect(vale.name).toBe('<%= className %>');
|
21
|
+
done();
|
22
|
+
});
|
23
|
+
});
|
24
|
+
});
|
@@ -9,7 +9,9 @@ describe(<%= className %>Store.name, () => {
|
|
9
9
|
get: jest.fn(),
|
10
10
|
};
|
11
11
|
|
12
|
-
|
12
|
+
afterEach(() => jest.clearAllMocks());
|
13
|
+
|
14
|
+
function setup() {
|
13
15
|
TestBed.configureTestingModule({
|
14
16
|
providers: [
|
15
17
|
{
|
@@ -18,14 +20,10 @@ describe(<%= className %>Store.name, () => {
|
|
18
20
|
},
|
19
21
|
],
|
20
22
|
});
|
21
|
-
});
|
22
|
-
|
23
|
-
afterEach(() => jest.clearAllMocks());
|
24
|
-
|
25
|
-
function setup() {
|
26
|
-
const store = TestBed.inject(<%= className %>Store);
|
27
23
|
|
28
|
-
return {
|
24
|
+
return {
|
25
|
+
store: TestBed.inject(<%= className %>Store)
|
26
|
+
};
|
29
27
|
}
|
30
28
|
|
31
29
|
it('should initialize', () => {
|
package/src/feature/schema.d.ts
CHANGED
package/src/feature/schema.json
CHANGED
@@ -4,14 +4,15 @@
|
|
4
4
|
"title": "",
|
5
5
|
"type": "object",
|
6
6
|
"properties": {
|
7
|
-
"
|
7
|
+
"path": {
|
8
8
|
"type": "string",
|
9
|
-
"description": "
|
9
|
+
"description": "Path to the feature to be generated starting from the root of the workspace",
|
10
|
+
"examples": ["app/features/feature-name", "libs/feature-name"],
|
10
11
|
"$default": {
|
11
12
|
"$source": "argv",
|
12
13
|
"index": 0
|
13
14
|
},
|
14
|
-
"x-prompt": "
|
15
|
+
"x-prompt": "Path to the feature to be generated starting from the root of the workspace"
|
15
16
|
},
|
16
17
|
"prefix": {
|
17
18
|
"type": "string",
|
@@ -19,5 +20,5 @@
|
|
19
20
|
"x-prompt": "What prefix would you like to use?"
|
20
21
|
}
|
21
22
|
},
|
22
|
-
"required": ["
|
23
|
+
"required": ["path", "prefix"]
|
23
24
|
}
|
package/src/ng-add/compat.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: (generatorOptions:
|
1
|
+
declare const _default: (generatorOptions: import("./schema").AddOptionsSchema) => (tree: any, context: any) => Promise<any>;
|
2
2
|
export default _default;
|
package/src/ng-add/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
|
-
|
3
|
-
export
|
2
|
+
import { AddOptionsSchema } from './schema';
|
3
|
+
export declare function addGenerator(tree: Tree, options: AddOptionsSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
package/src/ng-add/index.js
CHANGED
@@ -3,58 +3,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addGenerator = addGenerator;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
* @param packageName Name of the package
|
10
|
-
* @returns Latest version string or 'latest'
|
11
|
-
*/
|
12
|
-
function getLatestVersion(packageName) {
|
13
|
-
try {
|
14
|
-
// Execute npm command to get the latest version
|
15
|
-
const latestVersion = (0, child_process_1.execSync)(`npm show ${packageName} version`, {
|
16
|
-
encoding: 'utf-8',
|
17
|
-
}).trim();
|
18
|
-
return latestVersion;
|
19
|
-
}
|
20
|
-
catch (error) {
|
21
|
-
devkit_1.logger.warn(`Could not fetch latest version for ${packageName}, using 'latest' instead`);
|
22
|
-
return 'latest';
|
23
|
-
}
|
24
|
-
}
|
25
|
-
function addGenerator(tree) {
|
6
|
+
const with_packages_util_1 = require("../utils/with-packages.util");
|
7
|
+
const update_app_config_util_1 = require("../utils/update-app-config.util");
|
8
|
+
function addGenerator(tree, options) {
|
26
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
27
10
|
const tasks = [];
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
11
|
+
if (options.prettier) {
|
12
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, (0, with_packages_util_1.withPackages)('prettier')));
|
13
|
+
if (!tree.exists('.prettierrc')) {
|
14
|
+
tree.write('.prettierrc', JSON.stringify({ semi: false }, null, 2));
|
15
|
+
}
|
16
|
+
}
|
17
|
+
if (options.tailwind) {
|
18
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, (0, with_packages_util_1.withPackages)('tailwindcss', '@tailwindcss/postcss', 'postcss'), {}));
|
19
|
+
tree.write('.postcssrc.json', `{ "plugins": { "@tailwindcss/postcss": {} } }`);
|
20
|
+
const styles = tree.read('src/styles.css', 'utf-8');
|
21
|
+
tree.write('src/styles.css', `@import "primeicons/primeicons.css";
|
22
|
+
@import "tailwindcss";
|
23
|
+
${options.primeng ? '@plugin "tailwindcss-primeui";' : ''}
|
24
|
+
\n
|
25
|
+
${styles}`);
|
26
|
+
}
|
27
|
+
if (options.primeng) {
|
28
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, (0, with_packages_util_1.withPackages)('primeng', 'primeicons', '@primeng/themes'), {}));
|
29
|
+
yield (0, update_app_config_util_1.updateAppConfig)(tree, [
|
30
|
+
{
|
31
|
+
provider: 'provideAnimationsAsync()',
|
32
|
+
moduleSpecifier: '@angular/platform-browser/animations/async',
|
33
|
+
namedImports: ['provideAnimationsAsync'],
|
34
|
+
},
|
35
|
+
{
|
36
|
+
provider: 'providePrimeNG({ theme: { preset: Aura } })',
|
37
|
+
moduleSpecifier: 'primeng/config',
|
38
|
+
namedImports: ['providePrimeNG'],
|
39
|
+
},
|
40
|
+
{
|
41
|
+
provider: null,
|
42
|
+
moduleSpecifier: '@primeng/themes/aura',
|
43
|
+
defaultImport: 'Aura',
|
44
|
+
},
|
45
|
+
]);
|
46
|
+
}
|
47
|
+
if (options.tailwind && options.primeng) {
|
48
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, (0, with_packages_util_1.withPackages)('tailwindcss-primeui')));
|
35
49
|
}
|
36
|
-
// 2. Add Tailwind
|
37
|
-
const tailwindcss = getLatestVersion('tailwindcss');
|
38
|
-
const postcss = getLatestVersion('postcss');
|
39
|
-
const tailwindPostcss = getLatestVersion('@tailwindcss/postcss');
|
40
|
-
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
41
|
-
tailwindcss,
|
42
|
-
'@tailwindcss/postcss': tailwindPostcss,
|
43
|
-
postcss,
|
44
|
-
}));
|
45
|
-
tree.write('.postcssrc.json', `{
|
46
|
-
"plugins": {
|
47
|
-
"@tailwindcss/postcss": {}
|
48
|
-
}
|
49
|
-
}`);
|
50
|
-
tree.write('src/styles.css', `@import "tailwindcss";`);
|
51
|
-
// 3. Run ng add @angular-eslint/schematics
|
52
|
-
(0, child_process_1.execSync)('npx ng add @angular-eslint/schematics --skip-confirmation', {
|
53
|
-
stdio: 'inherit',
|
54
|
-
});
|
55
50
|
yield (0, devkit_1.formatFiles)(tree);
|
56
|
-
return (0, devkit_1.runTasksInSerial)(...tasks, () =>
|
51
|
+
return (0, devkit_1.runTasksInSerial)(...tasks, () => {
|
52
|
+
(0, devkit_1.installPackagesTask)(tree);
|
53
|
+
});
|
57
54
|
});
|
58
55
|
}
|
59
|
-
exports.default = addGenerator;
|
60
56
|
//# sourceMappingURL=index.js.map
|
package/src/ng-add/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/ng-add/index.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/ng-add/index.ts"],"names":[],"mappings":";;AAYA,oCAiFC;;AA7FD,uCAMoB;AACpB,oEAA2D;AAG3D,4EAAkE;AAElE,SAAsB,YAAY,CAAC,IAAU,EAAE,OAAyB;;QACtE,MAAM,KAAK,GAAG,EAAE,CAAC;QAEjB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CACR,IAAA,qCAA4B,EAAC,IAAI,EAAE,EAAE,EAAE,IAAA,iCAAY,EAAC,UAAU,CAAC,CAAC,CACjE,CAAC;YAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;gBAChC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CACR,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,iCAAY,EAAC,aAAa,EAAE,sBAAsB,EAAE,SAAS,CAAC,EAC9D,EAAE,CACH,CACF,CAAC;YAEF,IAAI,CAAC,KAAK,CACR,iBAAiB,EACjB,+CAA+C,CAChD,CAAC;YAEF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,KAAK,CACR,gBAAgB,EAChB;;EAEJ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE;;EAEvD,MAAM,EAAE,CACL,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CACR,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,iCAAY,EAAC,SAAS,EAAE,YAAY,EAAE,iBAAiB,CAAC,EACxD,EAAE,CACH,CACF,CAAC;YAEF,MAAM,IAAA,wCAAe,EAAC,IAAI,EAAE;gBAC1B;oBACE,QAAQ,EAAE,0BAA0B;oBACpC,eAAe,EAAE,4CAA4C;oBAC7D,YAAY,EAAE,CAAC,wBAAwB,CAAC;iBACzC;gBACD;oBACE,QAAQ,EAAE,6CAA6C;oBACvD,eAAe,EAAE,gBAAgB;oBACjC,YAAY,EAAE,CAAC,gBAAgB,CAAC;iBACjC;gBACD;oBACE,QAAQ,EAAE,IAAI;oBACd,eAAe,EAAE,sBAAsB;oBACvC,aAAa,EAAE,MAAM;iBACtB;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CACR,IAAA,qCAA4B,EAC1B,IAAI,EACJ,EAAE,EACF,IAAA,iCAAY,EAAC,qBAAqB,CAAC,CACpC,CACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,EAAE,GAAG,EAAE;YACrC,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
package/src/ng-add/schema.json
CHANGED
@@ -3,6 +3,19 @@
|
|
3
3
|
"$id": "Add",
|
4
4
|
"title": "Abelfubuize your project",
|
5
5
|
"type": "object",
|
6
|
-
"properties": {
|
6
|
+
"properties": {
|
7
|
+
"tailwind": {
|
8
|
+
"type": "boolean",
|
9
|
+
"description": "Add Tailwind CSS to your project"
|
10
|
+
},
|
11
|
+
"prettier": {
|
12
|
+
"type": "boolean",
|
13
|
+
"description": "Add Prettier to your project"
|
14
|
+
},
|
15
|
+
"primeng": {
|
16
|
+
"type": "boolean",
|
17
|
+
"description": "Add PrimeNG to your project"
|
18
|
+
}
|
19
|
+
},
|
7
20
|
"required": []
|
8
21
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.npmLatestVersion = npmLatestVersion;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
6
|
+
/**
|
7
|
+
* Returns the latest version of a package
|
8
|
+
* @param packageName Name of the package
|
9
|
+
* @returns Latest version string or 'latest'
|
10
|
+
*/
|
11
|
+
function npmLatestVersion(packageName) {
|
12
|
+
try {
|
13
|
+
const latestVersion = (0, node_child_process_1.execSync)(`npm show ${packageName} version`, {
|
14
|
+
encoding: 'utf-8',
|
15
|
+
}).trim();
|
16
|
+
return latestVersion;
|
17
|
+
}
|
18
|
+
catch (_a) {
|
19
|
+
devkit_1.logger.warn(`Could not fetch latest version for ${packageName}, using 'latest' instead`);
|
20
|
+
return 'latest';
|
21
|
+
}
|
22
|
+
}
|
23
|
+
//# sourceMappingURL=npm-latest-version.util.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"npm-latest-version.util.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/npm-latest-version.util.ts"],"names":[],"mappings":";;AAQA,4CAcC;AAtBD,uCAAoC;AACpC,2DAA8C;AAE9C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,6BAAQ,EAAC,YAAY,WAAW,UAAU,EAAE;YAChE,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,WAAM,CAAC;QACP,eAAM,CAAC,IAAI,CACT,sCAAsC,WAAW,0BAA0B,CAC5E,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
2
|
+
interface ProviderConfig {
|
3
|
+
provider: string | null;
|
4
|
+
moduleSpecifier: string;
|
5
|
+
namedImports?: string[];
|
6
|
+
defaultImport?: string;
|
7
|
+
}
|
8
|
+
export declare function updateAppConfig(tree: Tree, providers: ProviderConfig[]): Promise<void>;
|
9
|
+
export {};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.updateAppConfig = updateAppConfig;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const path_1 = require("path");
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
7
|
+
const typescript_1 = require("typescript");
|
8
|
+
function updateAppConfig(tree, providers) {
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
10
|
+
const configPath = 'src/app/app.config.ts';
|
11
|
+
if (!tree.exists(configPath)) {
|
12
|
+
throw new Error(`File ${configPath} does not exist`);
|
13
|
+
}
|
14
|
+
const project = new ts_morph_1.Project();
|
15
|
+
const filePath = (0, path_1.join)(process.cwd(), configPath);
|
16
|
+
const sourceFile = project.createSourceFile(filePath, tree.read(configPath, 'utf-8'), { overwrite: true });
|
17
|
+
for (const imp of providers) {
|
18
|
+
const existing = sourceFile
|
19
|
+
.getImportDeclarations()
|
20
|
+
.find((d) => d.getModuleSpecifierValue() === imp.moduleSpecifier);
|
21
|
+
if (existing)
|
22
|
+
continue;
|
23
|
+
sourceFile.addImportDeclaration({
|
24
|
+
moduleSpecifier: imp.moduleSpecifier,
|
25
|
+
namedImports: imp.namedImports,
|
26
|
+
defaultImport: imp.defaultImport,
|
27
|
+
});
|
28
|
+
}
|
29
|
+
// Find the appConfig object
|
30
|
+
const appConfig = sourceFile.getVariableDeclaration('appConfig');
|
31
|
+
if (!appConfig) {
|
32
|
+
throw new Error(`appConfig not found in ${configPath}`);
|
33
|
+
}
|
34
|
+
const initializer = appConfig.getInitializerIfKind(typescript_1.SyntaxKind.ObjectLiteralExpression);
|
35
|
+
const providersProp = initializer === null || initializer === void 0 ? void 0 : initializer.getProperty('providers');
|
36
|
+
if (!providersProp) {
|
37
|
+
throw new Error(`providers not found in appConfig`);
|
38
|
+
}
|
39
|
+
const array = providersProp.getFirstDescendantByKind(typescript_1.SyntaxKind.ArrayLiteralExpression);
|
40
|
+
if (!array) {
|
41
|
+
throw new Error(`Array not found in providers`);
|
42
|
+
}
|
43
|
+
// Append new providers if not already added
|
44
|
+
const existing = array.getElements().map((e) => e.getText());
|
45
|
+
for (const { provider } of providers.filter((p) => p.provider)) {
|
46
|
+
if (!existing.includes(provider)) {
|
47
|
+
array.addElement(provider);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
tree.write(configPath, sourceFile.getFullText());
|
51
|
+
});
|
52
|
+
}
|
53
|
+
//# sourceMappingURL=update-app-config.util.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-app-config.util.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/update-app-config.util.ts"],"names":[],"mappings":";;AAYA,0CA+DC;;AA1ED,+BAA4B;AAC5B,uCAAmC;AACnC,2CAAwC;AASxC,SAAsB,eAAe,CAAC,IAAU,EAAE,SAA2B;;QAC3E,MAAM,UAAU,GAAG,uBAAuB,CAAC;QAE3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,QAAQ,UAAU,iBAAiB,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,kBAAO,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CACzC,QAAQ,EACR,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAC9B,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,UAAU;iBACxB,qBAAqB,EAAE;iBACvB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB,EAAE,KAAK,GAAG,CAAC,eAAe,CAAC,CAAC;YAEpE,IAAI,QAAQ;gBAAE,SAAS;YAEvB,UAAU,CAAC,oBAAoB,CAAC;gBAC9B,eAAe,EAAE,GAAG,CAAC,eAAe;gBACpC,YAAY,EAAE,GAAG,CAAC,YAAY;gBAC9B,aAAa,EAAE,GAAG,CAAC,aAAa;aACjC,CAAC,CAAC;QACL,CAAC;QAED,4BAA4B;QAC5B,MAAM,SAAS,GAAG,UAAU,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;QACjE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,WAAW,GAAG,SAAS,CAAC,oBAAoB,CAChD,uBAAU,CAAC,uBAAuB,CACnC,CAAC;QAEF,MAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;QAE5D,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,KAAK,GAAG,aAAa,CAAC,wBAAwB,CAClD,uBAAU,CAAC,sBAAsB,CAClC,CAAC;QAEF,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAE7D,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IACnD,CAAC;CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* This function takes an array of package names and returns an object
|
3
|
+
* where the keys are the package names and the values are the latest
|
4
|
+
* versions of those packages.
|
5
|
+
*
|
6
|
+
* @param packages - An array of package names.
|
7
|
+
* @returns An object with package names as keys and their latest versions as values.
|
8
|
+
*/
|
9
|
+
export declare function withPackages(...packages: string[]): Record<string, string>;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.withPackages = withPackages;
|
4
|
+
const npm_latest_version_util_1 = require("./npm-latest-version.util");
|
5
|
+
/**
|
6
|
+
* This function takes an array of package names and returns an object
|
7
|
+
* where the keys are the package names and the values are the latest
|
8
|
+
* versions of those packages.
|
9
|
+
*
|
10
|
+
* @param packages - An array of package names.
|
11
|
+
* @returns An object with package names as keys and their latest versions as values.
|
12
|
+
*/
|
13
|
+
function withPackages(...packages) {
|
14
|
+
return packages.reduce((acc, item) => (Object.assign(Object.assign({}, acc), { [item]: (0, npm_latest_version_util_1.npmLatestVersion)(item) })), {});
|
15
|
+
}
|
16
|
+
//# sourceMappingURL=with-packages.util.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"with-packages.util.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/with-packages.util.ts"],"names":[],"mappings":";;AAUA,oCAKC;AAfD,uEAA6D;AAE7D;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,GAAG,QAAkB;IAChD,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,IAAI,CAAC,EAAE,IAAA,0CAAgB,EAAC,IAAI,CAAC,IAAG,EAC3D,EAAE,CACH,CAAC;AACJ,CAAC"}
|