@ng-prism/core 21.12.0-beta.2 → 23.0.0-beta.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/README.md +10 -13
- package/dist/app/canvas/prism-canvas-bg-pill.component.js +1 -1
- package/dist/app/canvas/prism-canvas-rulers.component.js +5 -3
- package/dist/app/canvas/prism-canvas-toolbar.component.js +1 -1
- package/dist/app/canvas/prism-template-popover.component.js +7 -4
- package/dist/app/component-head/prism-component-head.component.js +20 -11
- package/dist/app/component-head/prism-stat.component.js +9 -5
- package/dist/app/component-header/prism-component-header.component.js +1 -1
- package/dist/app/controls/boolean-control.component.js +7 -4
- package/dist/app/controls/json-control.component.js +19 -10
- package/dist/app/controls/number-control.component.js +7 -4
- package/dist/app/controls/string-control.component.js +7 -4
- package/dist/app/controls/union-control.component.js +9 -5
- package/dist/app/directives/prism-resizer.directive.js +8 -4
- package/dist/app/header/prism-header-widget-host.component.js +5 -3
- package/dist/app/header/prism-header.component.d.ts.map +1 -1
- package/dist/app/header/prism-header.component.js +15 -10
- package/dist/app/icons/prism-icon.component.js +5 -3
- package/dist/app/layout-menu/prism-layout-menu.component.js +2 -1
- package/dist/app/page-renderer/prism-page-renderer.component.d.ts.map +1 -1
- package/dist/app/page-renderer/prism-page-renderer.component.js +13 -16
- package/dist/app/panels/a11y/a11y-audit.service.js +8 -4
- package/dist/app/panels/a11y/a11y-header-badge.component.js +3 -2
- package/dist/app/panels/a11y/a11y-keyboard-overlay.component.js +3 -2
- package/dist/app/panels/a11y/a11y-keyboard.component.js +3 -2
- package/dist/app/panels/a11y/a11y-overlay-host.component.js +11 -6
- package/dist/app/panels/a11y/a11y-panel-state.service.js +2 -1
- package/dist/app/panels/a11y/a11y-panel.component.js +7 -4
- package/dist/app/panels/a11y/a11y-perspective.service.js +2 -1
- package/dist/app/panels/a11y/a11y-score.component.js +7 -4
- package/dist/app/panels/a11y/a11y-sr-overlay.component.js +5 -3
- package/dist/app/panels/a11y/a11y-sr.component.js +3 -2
- package/dist/app/panels/a11y/a11y-tree.component.js +14 -8
- package/dist/app/panels/a11y/a11y-violations.component.d.ts +1 -1
- package/dist/app/panels/a11y/a11y-violations.component.d.ts.map +1 -1
- package/dist/app/panels/a11y/a11y-violations.component.js +9 -11
- package/dist/app/panels/a11y/a11y.types.d.ts.map +1 -1
- package/dist/app/panels/controls/prism-controls-panel.component.js +3 -2
- package/dist/app/panels/events/prism-events-panel.component.js +3 -2
- package/dist/app/panels/events/prism-json-node.component.js +14 -7
- package/dist/app/panels/panel-host/prism-panel-host.component.js +15 -8
- package/dist/app/provide-prism.d.ts.map +1 -1
- package/dist/app/provide-prism.js +12 -3
- package/dist/app/renderer/prism-renderer.component.d.ts.map +1 -1
- package/dist/app/renderer/prism-renderer.component.js +9 -6
- package/dist/app/services/prism-canvas.service.js +8 -4
- package/dist/app/services/prism-event-log.service.js +2 -1
- package/dist/app/services/prism-layout.service.js +16 -8
- package/dist/app/services/prism-manifest.service.js +10 -5
- package/dist/app/services/prism-navigation.service.d.ts.map +1 -1
- package/dist/app/services/prism-navigation.service.js +27 -19
- package/dist/app/services/prism-panel.service.js +6 -3
- package/dist/app/services/prism-plugin.service.js +14 -7
- package/dist/app/services/prism-renderer.service.js +10 -5
- package/dist/app/services/prism-search.service.js +6 -3
- package/dist/app/services/prism-theme.service.js +4 -2
- package/dist/app/services/prism-variant-bg.service.js +8 -4
- package/dist/app/shell/prism-shell.component.js +7 -4
- package/dist/app/sidebar/prism-sidebar.component.js +15 -8
- package/dist/app/variant-ribbon/prism-variant-ribbon.component.js +7 -4
- package/dist/app/view-tab-bar/prism-view-panel-host.component.js +8 -4
- package/dist/app/view-tab-bar/prism-view-tab-bar.component.js +2 -1
- package/dist/builder/a11y/a11y-report-reader.d.ts.map +1 -1
- package/dist/builder/a11y/a11y-report-reader.js +20 -4
- package/dist/builder/build/index.d.ts.map +1 -1
- package/dist/builder/build/index.js +11 -4
- package/dist/builder/build/schema.d.ts +1 -0
- package/dist/builder/build/schema.d.ts.map +1 -1
- package/dist/builder/manifest/runtime-manifest.generator.d.ts.map +1 -1
- package/dist/builder/manifest/runtime-manifest.generator.js +11 -3
- package/dist/builder/plugin-runner/plugin-runner.d.ts.map +1 -1
- package/dist/builder/serve/index.d.ts.map +1 -1
- package/dist/builder/serve/index.js +21 -6
- package/dist/builder/serve/schema.d.ts +1 -0
- package/dist/builder/serve/schema.d.ts.map +1 -1
- package/dist/builder/shared/prism-pipeline.d.ts +2 -0
- package/dist/builder/shared/prism-pipeline.d.ts.map +1 -1
- package/dist/builder/shared/prism-pipeline.js +3 -5
- package/dist/builder/shared/resolve-cache-dir.d.ts +8 -0
- package/dist/builder/shared/resolve-cache-dir.d.ts.map +1 -0
- package/dist/builder/shared/resolve-cache-dir.js +12 -0
- package/dist/decorator/index.d.ts +1 -1
- package/dist/decorator/index.d.ts.map +1 -1
- package/dist/decorator/showcase.decorator.d.ts.map +1 -1
- package/dist/decorator/showcase.types.d.ts.map +1 -1
- package/dist/schematics/migrations/v21-13-manifest-cache/index.d.ts +3 -0
- package/dist/schematics/migrations/v21-13-manifest-cache/index.d.ts.map +1 -0
- package/dist/schematics/migrations/v21-13-manifest-cache/index.js +103 -0
- package/dist/schematics/ng-add/index.d.ts.map +1 -1
- package/dist/schematics/ng-add/index.js +56 -39
- package/dist/schematics/utils/config-ast.d.ts +17 -0
- package/dist/schematics/utils/config-ast.d.ts.map +1 -0
- package/dist/schematics/utils/config-ast.js +118 -0
- package/dist/schematics/utils/index.d.ts +3 -0
- package/dist/schematics/utils/index.d.ts.map +1 -0
- package/dist/schematics/utils/index.js +2 -0
- package/dist/schematics/utils/tsconfig-paths.d.ts +8 -0
- package/dist/schematics/utils/tsconfig-paths.d.ts.map +1 -0
- package/dist/schematics/utils/tsconfig-paths.js +20 -0
- package/package.json +17 -6
- package/schematics/migrations.json +10 -0
- package/src/builder/build/schema.json +4 -0
- package/src/builder/serve/schema.json +4 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { createBuilder } from '@angular-devkit/architect';
|
|
1
|
+
import { createBuilder, } from '@angular-devkit/architect';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
|
-
import { runPrismPipeline, createPipelineState } from '../shared/prism-pipeline.js';
|
|
4
|
+
import { runPrismPipeline, createPipelineState, } from '../shared/prism-pipeline.js';
|
|
5
|
+
import { resolveCacheDir } from '../shared/resolve-cache-dir.js';
|
|
5
6
|
import { startWatcher } from '../watcher/index.js';
|
|
6
7
|
async function createServeBuilder(options, context) {
|
|
8
|
+
const cacheDir = resolveCacheDir(options.cacheDir, context.workspaceRoot);
|
|
7
9
|
const pipelineOptions = {
|
|
8
10
|
entryPoint: options.entryPoint,
|
|
9
|
-
libraryImportPath: options.libraryImportPath ??
|
|
11
|
+
libraryImportPath: options.libraryImportPath ??
|
|
12
|
+
options.libraryProject ??
|
|
13
|
+
options.prismProject,
|
|
10
14
|
prismProject: options.prismProject,
|
|
11
15
|
configFile: options.configFile ?? 'ng-prism.config.ts',
|
|
16
|
+
cacheDir,
|
|
12
17
|
};
|
|
13
18
|
const state = createPipelineState();
|
|
14
19
|
await runPrismPipeline(pipelineOptions, context, state);
|
|
@@ -42,9 +47,19 @@ async function createServeBuilder(options, context) {
|
|
|
42
47
|
return new Promise((resolve, reject) => {
|
|
43
48
|
let lastOutput;
|
|
44
49
|
run.output.subscribe({
|
|
45
|
-
next: (output) => {
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
next: (output) => {
|
|
51
|
+
lastOutput = output;
|
|
52
|
+
},
|
|
53
|
+
error: (err) => {
|
|
54
|
+
cleanupSignals();
|
|
55
|
+
shutdown();
|
|
56
|
+
reject(err);
|
|
57
|
+
},
|
|
58
|
+
complete: () => {
|
|
59
|
+
cleanupSignals();
|
|
60
|
+
watcher.close();
|
|
61
|
+
resolve(lastOutput ?? { success: false });
|
|
62
|
+
},
|
|
48
63
|
});
|
|
49
64
|
});
|
|
50
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/builder/serve/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/builder/serve/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -5,6 +5,8 @@ export interface PrismPipelineOptions {
|
|
|
5
5
|
libraryImportPath: string;
|
|
6
6
|
prismProject: string;
|
|
7
7
|
configFile: string;
|
|
8
|
+
/** Absolute path. If omitted, defaults to `<workspaceRoot>/.ng-prism/<prismProject>`. */
|
|
9
|
+
cacheDir?: string;
|
|
8
10
|
}
|
|
9
11
|
export interface PrismPipelineResult {
|
|
10
12
|
manifestPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prism-pipeline.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/prism-pipeline.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAYpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"prism-pipeline.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/prism-pipeline.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAYpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,oGAAoG;IACpG,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,IAAI,kBAAkB,CAExD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAyE9B"}
|
|
@@ -45,11 +45,9 @@ export async function runPrismPipeline(options, context, state) {
|
|
|
45
45
|
pages: manifest.pages,
|
|
46
46
|
meta: manifest.meta,
|
|
47
47
|
});
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const manifestPath = join(workspaceRoot, sourceRoot, 'prism-manifest.ts');
|
|
52
|
-
mkdirSync(join(workspaceRoot, sourceRoot), { recursive: true });
|
|
48
|
+
const cacheDir = options.cacheDir ?? join(workspaceRoot, '.ng-prism', options.prismProject);
|
|
49
|
+
const manifestPath = join(cacheDir, 'prism-manifest.ts');
|
|
50
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
53
51
|
const written = writeManifestIfChanged(manifestPath, source);
|
|
54
52
|
const pageCount = (manifest.pages ?? []).length;
|
|
55
53
|
context.reportStatus('');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a user-provided `cacheDir` builder option to an absolute path
|
|
3
|
+
* (or `undefined` when the option is empty/unset).
|
|
4
|
+
*
|
|
5
|
+
* Relative paths resolve against `workspaceRoot`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCacheDir(option: string | undefined, workspaceRoot: string): string | undefined;
|
|
8
|
+
//# sourceMappingURL=resolve-cache-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-cache-dir.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/resolve-cache-dir.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAGpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { join, isAbsolute } from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a user-provided `cacheDir` builder option to an absolute path
|
|
4
|
+
* (or `undefined` when the option is empty/unset).
|
|
5
|
+
*
|
|
6
|
+
* Relative paths resolve against `workspaceRoot`.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveCacheDir(option, workspaceRoot) {
|
|
9
|
+
if (!option)
|
|
10
|
+
return undefined;
|
|
11
|
+
return isAbsolute(option) ? option : join(workspaceRoot, option);
|
|
12
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { ShowcaseConfig, Variant, ComponentStatus, InputsOf } from './showcase.types.js';
|
|
1
|
+
export type { ShowcaseConfig, Variant, ComponentStatus, InputsOf, } from './showcase.types.js';
|
|
2
2
|
export { Showcase } from './showcase.decorator.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AACA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showcase.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"showcase.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,cAAc,CAEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showcase.types.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAOD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,
|
|
1
|
+
{"version":3,"file":"showcase.types.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAOD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAC5D,GAAG,EACH,MAAM,MAAM,CACb,GACG,MAAM,GACN,KAAK,CAAC;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAC3C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB;KACG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,GAC5D,CAAC,GACD,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC;AAEN,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2IAA2I;IAC3I,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iJAAiJ;IACjJ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd,6HAA6H;IAC7H,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9B,mPAAmP;IACnP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,0IAA0I;IAC1I,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,qFAAqF;IACrF,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/schematics/migrations/v21-13-manifest-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AA4H/E,wBAAgB,OAAO,IAAI,IAAI,CAgB9B"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { addTsConfigPath } from '../../utils/tsconfig-paths.js';
|
|
2
|
+
const OLD_IMPORT = /^import\s+\{\s*PRISM_RUNTIME_MANIFEST\s*\}\s+from\s+['"](?:\.\/prism-manifest|prism-manifest)['"]\s*;?$/m;
|
|
3
|
+
function buildNewImport(prismProject) {
|
|
4
|
+
return `import { PRISM_RUNTIME_MANIFEST } from 'prism-manifest/${prismProject}';`;
|
|
5
|
+
}
|
|
6
|
+
function readWorkspace(tree) {
|
|
7
|
+
const buffer = tree.read('angular.json');
|
|
8
|
+
if (!buffer)
|
|
9
|
+
return undefined;
|
|
10
|
+
return JSON.parse(buffer.toString('utf-8'));
|
|
11
|
+
}
|
|
12
|
+
function findPrismProjects(workspace) {
|
|
13
|
+
const projects = workspace.projects ?? {};
|
|
14
|
+
const result = [];
|
|
15
|
+
for (const [, project] of Object.entries(projects)) {
|
|
16
|
+
const architect = project.architect ?? {};
|
|
17
|
+
for (const target of Object.values(architect)) {
|
|
18
|
+
if (target.builder === '@ng-prism/core:serve') {
|
|
19
|
+
const prismProject = target.options?.['prismProject'];
|
|
20
|
+
if (typeof prismProject === 'string' &&
|
|
21
|
+
!result.includes(prismProject)) {
|
|
22
|
+
result.push(prismProject);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
function rewriteMainTs(tree, context, workspace, prismProject) {
|
|
30
|
+
const project = workspace.projects?.[prismProject];
|
|
31
|
+
const sourceRoot = project?.sourceRoot ?? `projects/${prismProject}/src`;
|
|
32
|
+
const mainPath = `${sourceRoot}/main.ts`;
|
|
33
|
+
const buffer = tree.read(mainPath);
|
|
34
|
+
if (!buffer)
|
|
35
|
+
return;
|
|
36
|
+
const newImport = buildNewImport(prismProject);
|
|
37
|
+
const content = buffer.toString('utf-8');
|
|
38
|
+
if (content.includes(newImport))
|
|
39
|
+
return;
|
|
40
|
+
if (!OLD_IMPORT.test(content)) {
|
|
41
|
+
context.logger.warn(`ng-prism migration: could not find PRISM_RUNTIME_MANIFEST import in ${mainPath}. ` +
|
|
42
|
+
`Update it manually to: ${newImport}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
tree.overwrite(mainPath, content.replace(OLD_IMPORT, newImport));
|
|
46
|
+
}
|
|
47
|
+
function addTsConfigMapping(tree) {
|
|
48
|
+
addTsConfigPath(tree, 'tsconfig.json', 'prism-manifest/*', [
|
|
49
|
+
'.ng-prism/*/prism-manifest.ts',
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
function ensureNgPrismGitignoreEntry(tree) {
|
|
53
|
+
const path = '.gitignore';
|
|
54
|
+
const entry = '.ng-prism/';
|
|
55
|
+
const buffer = tree.read(path);
|
|
56
|
+
if (!buffer) {
|
|
57
|
+
tree.create(path, entry + '\n');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const content = buffer.toString('utf-8');
|
|
61
|
+
if (content.split('\n').some((line) => line.trim() === entry))
|
|
62
|
+
return;
|
|
63
|
+
tree.overwrite(path, content.trimEnd() + '\n' + entry + '\n');
|
|
64
|
+
}
|
|
65
|
+
function deleteLegacyManifest(tree, workspace, prismProject) {
|
|
66
|
+
const project = workspace.projects?.[prismProject];
|
|
67
|
+
const sourceRoot = project?.sourceRoot ?? `projects/${prismProject}/src`;
|
|
68
|
+
const manifestPath = `${sourceRoot}/prism-manifest.ts`;
|
|
69
|
+
if (tree.exists(manifestPath)) {
|
|
70
|
+
tree.delete(manifestPath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function removeGitignoreEntry(tree, prismProject) {
|
|
74
|
+
const path = '.gitignore';
|
|
75
|
+
const buffer = tree.read(path);
|
|
76
|
+
if (!buffer)
|
|
77
|
+
return;
|
|
78
|
+
const targetEntry = `projects/${prismProject}/src/prism-manifest.ts`;
|
|
79
|
+
const content = buffer.toString('utf-8');
|
|
80
|
+
if (!content.includes(targetEntry))
|
|
81
|
+
return;
|
|
82
|
+
const cleaned = content
|
|
83
|
+
.split('\n')
|
|
84
|
+
.filter((line) => line.trim() !== targetEntry)
|
|
85
|
+
.join('\n');
|
|
86
|
+
tree.overwrite(path, cleaned);
|
|
87
|
+
}
|
|
88
|
+
export function migrate() {
|
|
89
|
+
return (tree, context) => {
|
|
90
|
+
const workspace = readWorkspace(tree);
|
|
91
|
+
if (!workspace)
|
|
92
|
+
return tree;
|
|
93
|
+
const prismProjects = findPrismProjects(workspace);
|
|
94
|
+
for (const prismProject of prismProjects) {
|
|
95
|
+
rewriteMainTs(tree, context, workspace, prismProject);
|
|
96
|
+
addTsConfigMapping(tree);
|
|
97
|
+
deleteLegacyManifest(tree, workspace, prismProject);
|
|
98
|
+
removeGitignoreEntry(tree, prismProject);
|
|
99
|
+
}
|
|
100
|
+
ensureNgPrismGitignoreEntry(tree);
|
|
101
|
+
return tree;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAiWtD,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAWvD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { chain, SchematicsException, } from '@angular-devkit/schematics';
|
|
2
|
-
import {
|
|
2
|
+
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
|
+
import { addTsConfigPath } from '../utils/tsconfig-paths.js';
|
|
3
4
|
function readWorkspace(tree) {
|
|
4
5
|
const buffer = tree.read('angular.json');
|
|
5
6
|
if (!buffer) {
|
|
@@ -26,7 +27,7 @@ function addPrismAppProject(options) {
|
|
|
26
27
|
"import { provideZonelessChangeDetection } from '@angular/core';",
|
|
27
28
|
"import { bootstrapApplication } from '@angular/platform-browser';",
|
|
28
29
|
"import { PrismShellComponent, providePrism } from '@ng-prism/core';",
|
|
29
|
-
|
|
30
|
+
`import { PRISM_RUNTIME_MANIFEST } from 'prism-manifest/${prismProjectName}';`,
|
|
30
31
|
"import config from 'ng-prism.config';",
|
|
31
32
|
'',
|
|
32
33
|
'bootstrapApplication(PrismShellComponent, {',
|
|
@@ -40,7 +41,7 @@ function addPrismAppProject(options) {
|
|
|
40
41
|
: [
|
|
41
42
|
"import { bootstrapApplication } from '@angular/platform-browser';",
|
|
42
43
|
"import { PrismShellComponent, providePrism } from '@ng-prism/core';",
|
|
43
|
-
|
|
44
|
+
`import { PRISM_RUNTIME_MANIFEST } from 'prism-manifest/${prismProjectName}';`,
|
|
44
45
|
"import config from 'ng-prism.config';",
|
|
45
46
|
'',
|
|
46
47
|
'bootstrapApplication(PrismShellComponent, {',
|
|
@@ -179,32 +180,20 @@ function addBuilderTargets(options) {
|
|
|
179
180
|
function addTsConfigPaths(options) {
|
|
180
181
|
return (tree, _context) => {
|
|
181
182
|
const tsConfigPath = 'tsconfig.json';
|
|
182
|
-
|
|
183
|
-
if (!buffer) {
|
|
183
|
+
if (!tree.read(tsConfigPath))
|
|
184
184
|
return tree;
|
|
185
|
-
}
|
|
186
|
-
const sourceText = buffer.toString('utf-8');
|
|
187
|
-
const tsConfig = parseJsonc(sourceText);
|
|
188
|
-
const existingPaths = tsConfig.compilerOptions?.paths ?? {};
|
|
189
185
|
const workspace = readWorkspace(tree);
|
|
190
186
|
const project = workspace.projects[options.project];
|
|
191
187
|
const sourceRoot = project.sourceRoot ?? `${project.root}/src`;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const edits = modifyJsonc(nextText, ['compilerOptions', 'paths', options.project], [`${sourceRoot}/public-api.ts`], { formattingOptions });
|
|
202
|
-
nextText = applyJsoncEdits(nextText, edits);
|
|
203
|
-
changed = true;
|
|
204
|
-
}
|
|
205
|
-
if (changed) {
|
|
206
|
-
tree.overwrite(tsConfigPath, nextText);
|
|
207
|
-
}
|
|
188
|
+
addTsConfigPath(tree, tsConfigPath, 'ng-prism.config', [
|
|
189
|
+
'ng-prism.config.ts',
|
|
190
|
+
]);
|
|
191
|
+
addTsConfigPath(tree, tsConfigPath, options.project, [
|
|
192
|
+
`${sourceRoot}/public-api.ts`,
|
|
193
|
+
]);
|
|
194
|
+
addTsConfigPath(tree, tsConfigPath, 'prism-manifest/*', [
|
|
195
|
+
'.ng-prism/*/prism-manifest.ts',
|
|
196
|
+
]);
|
|
208
197
|
return tree;
|
|
209
198
|
};
|
|
210
199
|
}
|
|
@@ -224,20 +213,30 @@ function createConfigFile() {
|
|
|
224
213
|
return tree;
|
|
225
214
|
};
|
|
226
215
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
216
|
+
const RUNTIME_PEER_DEPS = {
|
|
217
|
+
'highlight.js': '^11.0.0',
|
|
218
|
+
'ngx-highlightjs': '^14.0.0',
|
|
219
|
+
};
|
|
220
|
+
function addRuntimePeerDeps() {
|
|
221
|
+
return (tree, context) => {
|
|
222
|
+
const pkgPath = 'package.json';
|
|
223
|
+
const buffer = tree.read(pkgPath);
|
|
224
|
+
if (!buffer)
|
|
225
|
+
return tree;
|
|
226
|
+
const pkg = JSON.parse(buffer.toString('utf-8'));
|
|
227
|
+
pkg.devDependencies ??= {};
|
|
228
|
+
let changed = false;
|
|
229
|
+
for (const [name, version] of Object.entries(RUNTIME_PEER_DEPS)) {
|
|
230
|
+
const alreadyPresent = pkg.devDependencies[name] || pkg.dependencies?.[name];
|
|
231
|
+
if (!alreadyPresent) {
|
|
232
|
+
pkg.devDependencies[name] = version;
|
|
233
|
+
changed = true;
|
|
234
|
+
context.logger.info(` Added ${name}@${version} to devDependencies`);
|
|
235
|
+
}
|
|
238
236
|
}
|
|
239
|
-
|
|
240
|
-
tree.
|
|
237
|
+
if (changed) {
|
|
238
|
+
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
239
|
+
context.addTask(new NodePackageInstallTask());
|
|
241
240
|
}
|
|
242
241
|
return tree;
|
|
243
242
|
};
|
|
@@ -255,6 +254,23 @@ function logSetupSummary(options) {
|
|
|
255
254
|
context.logger.info('');
|
|
256
255
|
};
|
|
257
256
|
}
|
|
257
|
+
function addNgPrismGitignoreEntry() {
|
|
258
|
+
return (tree) => {
|
|
259
|
+
const entry = '.ng-prism/';
|
|
260
|
+
const gitignorePath = '.gitignore';
|
|
261
|
+
const buffer = tree.read(gitignorePath);
|
|
262
|
+
if (buffer) {
|
|
263
|
+
const content = buffer.toString('utf-8');
|
|
264
|
+
if (content.split('\n').some((line) => line.trim() === entry))
|
|
265
|
+
return tree;
|
|
266
|
+
tree.overwrite(gitignorePath, content.trimEnd() + '\n' + entry + '\n');
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
tree.create(gitignorePath, entry + '\n');
|
|
270
|
+
}
|
|
271
|
+
return tree;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
258
274
|
function addStripShowcaseScript(options) {
|
|
259
275
|
return (tree) => {
|
|
260
276
|
const pkgPath = 'package.json';
|
|
@@ -277,9 +293,10 @@ export function ngAdd(options) {
|
|
|
277
293
|
addPrismAppProject(options),
|
|
278
294
|
addBuilderTargets(options),
|
|
279
295
|
addTsConfigPaths(options),
|
|
296
|
+
addNgPrismGitignoreEntry(),
|
|
280
297
|
createConfigFile(),
|
|
281
298
|
addStripShowcaseScript(options),
|
|
282
|
-
|
|
299
|
+
addRuntimePeerDeps(),
|
|
283
300
|
logSetupSummary(options),
|
|
284
301
|
]);
|
|
285
302
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Tree } from '@angular-devkit/schematics';
|
|
2
|
+
export interface AddPluginToConfigOptions {
|
|
3
|
+
/** Named import binding, e.g. 'jsDocPlugin' */
|
|
4
|
+
importName: string;
|
|
5
|
+
/** Module specifier, e.g. '@ng-prism/plugin-jsdoc' */
|
|
6
|
+
importFrom: string;
|
|
7
|
+
/** Factory call to insert into plugins array, e.g. 'jsDocPlugin()' */
|
|
8
|
+
call: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Adds a plugin import + factory call to the user's ng-prism.config.ts.
|
|
12
|
+
* Idempotent: skips if import or call is already present.
|
|
13
|
+
* Throws SchematicsException on unsupported config shapes.
|
|
14
|
+
* Returns true if the file was changed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addPluginToConfig(tree: Tree, configPath: string, options: AddPluginToConfigOptions): boolean;
|
|
17
|
+
//# sourceMappingURL=config-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-ast.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAG5E,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAoGT"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { SchematicsException } from '@angular-devkit/schematics';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
/**
|
|
4
|
+
* Adds a plugin import + factory call to the user's ng-prism.config.ts.
|
|
5
|
+
* Idempotent: skips if import or call is already present.
|
|
6
|
+
* Throws SchematicsException on unsupported config shapes.
|
|
7
|
+
* Returns true if the file was changed.
|
|
8
|
+
*/
|
|
9
|
+
export function addPluginToConfig(tree, configPath, options) {
|
|
10
|
+
const buffer = tree.read(configPath);
|
|
11
|
+
if (!buffer) {
|
|
12
|
+
throw new SchematicsException(`${configPath} not found. Run "ng add @ng-prism/core" first.`);
|
|
13
|
+
}
|
|
14
|
+
const source = buffer.toString('utf-8');
|
|
15
|
+
const sf = ts.createSourceFile(configPath, source, ts.ScriptTarget.Latest,
|
|
16
|
+
/* setParentNodes */ true);
|
|
17
|
+
const imports = sf.statements.filter(ts.isImportDeclaration);
|
|
18
|
+
const defineConfigCall = findDefineConfigCall(sf);
|
|
19
|
+
if (!defineConfigCall) {
|
|
20
|
+
throw new SchematicsException('Unsupported config: defineConfig() call not found at default export.');
|
|
21
|
+
}
|
|
22
|
+
const arg = defineConfigCall.arguments[0];
|
|
23
|
+
if (!arg || !ts.isObjectLiteralExpression(arg)) {
|
|
24
|
+
throw new SchematicsException('Unsupported config: defineConfig argument must be an object literal.');
|
|
25
|
+
}
|
|
26
|
+
const objectLiteral = arg;
|
|
27
|
+
const pluginsProp = findPluginsProperty(objectLiteral);
|
|
28
|
+
if (pluginsProp && !ts.isArrayLiteralExpression(pluginsProp.initializer)) {
|
|
29
|
+
throw new SchematicsException('Unsupported config: plugins must be an array literal.');
|
|
30
|
+
}
|
|
31
|
+
const importAlreadyPresent = imports.some((imp) => importHasNamedBinding(imp, options.importFrom, options.importName));
|
|
32
|
+
const callAlreadyPresent = !!pluginsProp &&
|
|
33
|
+
pluginsProp.initializer.elements.some((el) => ts.isCallExpression(el) &&
|
|
34
|
+
ts.isIdentifier(el.expression) &&
|
|
35
|
+
el.expression.text === options.importName);
|
|
36
|
+
if (importAlreadyPresent && callAlreadyPresent)
|
|
37
|
+
return false;
|
|
38
|
+
const edits = [];
|
|
39
|
+
if (!importAlreadyPresent) {
|
|
40
|
+
const insertPos = imports.length > 0 ? imports[imports.length - 1].end : 0;
|
|
41
|
+
edits.push({
|
|
42
|
+
start: insertPos,
|
|
43
|
+
end: insertPos,
|
|
44
|
+
newText: `\nimport { ${options.importName} } from '${options.importFrom}';`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!callAlreadyPresent) {
|
|
48
|
+
if (!pluginsProp) {
|
|
49
|
+
const insertPos = objectLiteral.getStart(sf) + 1;
|
|
50
|
+
edits.push({
|
|
51
|
+
start: insertPos,
|
|
52
|
+
end: insertPos,
|
|
53
|
+
newText: `\n plugins: [${options.call}],`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const arr = pluginsProp.initializer;
|
|
58
|
+
if (arr.elements.length === 0) {
|
|
59
|
+
edits.push({
|
|
60
|
+
start: arr.getStart(sf),
|
|
61
|
+
end: arr.getEnd(),
|
|
62
|
+
newText: `[${options.call}]`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const lastElement = arr.elements[arr.elements.length - 1];
|
|
67
|
+
const insertPos = lastElement.end;
|
|
68
|
+
edits.push({
|
|
69
|
+
start: insertPos,
|
|
70
|
+
end: insertPos,
|
|
71
|
+
newText: `, ${options.call}`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
edits.sort((a, b) => b.start - a.start);
|
|
77
|
+
let result = source;
|
|
78
|
+
for (const e of edits) {
|
|
79
|
+
result = result.slice(0, e.start) + e.newText + result.slice(e.end);
|
|
80
|
+
}
|
|
81
|
+
tree.overwrite(configPath, result);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function findDefineConfigCall(sf) {
|
|
85
|
+
for (const stmt of sf.statements) {
|
|
86
|
+
if (!ts.isExportAssignment(stmt) || stmt.isExportEquals)
|
|
87
|
+
continue;
|
|
88
|
+
const expr = stmt.expression;
|
|
89
|
+
if (ts.isCallExpression(expr) &&
|
|
90
|
+
ts.isIdentifier(expr.expression) &&
|
|
91
|
+
expr.expression.text === 'defineConfig') {
|
|
92
|
+
return expr;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function findPluginsProperty(obj) {
|
|
98
|
+
for (const prop of obj.properties) {
|
|
99
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
100
|
+
ts.isIdentifier(prop.name) &&
|
|
101
|
+
prop.name.text === 'plugins') {
|
|
102
|
+
return prop;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function importHasNamedBinding(imp, moduleSpecifier, binding) {
|
|
108
|
+
if (!ts.isStringLiteral(imp.moduleSpecifier))
|
|
109
|
+
return false;
|
|
110
|
+
if (imp.moduleSpecifier.text !== moduleSpecifier)
|
|
111
|
+
return false;
|
|
112
|
+
const clause = imp.importClause;
|
|
113
|
+
if (!clause?.namedBindings)
|
|
114
|
+
return false;
|
|
115
|
+
if (!ts.isNamedImports(clause.namedBindings))
|
|
116
|
+
return false;
|
|
117
|
+
return clause.namedBindings.elements.some((el) => el.name.text === binding);
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
/**
|
|
3
|
+
* Adds `compilerOptions.paths[<key>] = <value>` to a tsconfig.json (JSONC-safe).
|
|
4
|
+
* Idempotent: does not overwrite an existing entry.
|
|
5
|
+
* Returns true when an entry was added, false otherwise (already present or file missing).
|
|
6
|
+
*/
|
|
7
|
+
export declare function addTsConfigPath(tree: Tree, tsConfigPath: string, key: string, value: string[]): boolean;
|
|
8
|
+
//# sourceMappingURL=tsconfig-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/tsconfig-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAevD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAkBT"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parse as parseJsonc, modify as modifyJsonc, applyEdits as applyJsoncEdits, } from 'jsonc-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Adds `compilerOptions.paths[<key>] = <value>` to a tsconfig.json (JSONC-safe).
|
|
4
|
+
* Idempotent: does not overwrite an existing entry.
|
|
5
|
+
* Returns true when an entry was added, false otherwise (already present or file missing).
|
|
6
|
+
*/
|
|
7
|
+
export function addTsConfigPath(tree, tsConfigPath, key, value) {
|
|
8
|
+
const buffer = tree.read(tsConfigPath);
|
|
9
|
+
if (!buffer)
|
|
10
|
+
return false;
|
|
11
|
+
const sourceText = buffer.toString('utf-8');
|
|
12
|
+
const parsed = parseJsonc(sourceText);
|
|
13
|
+
const existing = parsed.compilerOptions?.paths ?? {};
|
|
14
|
+
if (existing[key])
|
|
15
|
+
return false;
|
|
16
|
+
const edits = modifyJsonc(sourceText, ['compilerOptions', 'paths', key], value, { formattingOptions: { tabSize: 2, insertSpaces: true } });
|
|
17
|
+
const nextText = applyJsoncEdits(sourceText, edits);
|
|
18
|
+
tree.overwrite(tsConfigPath, nextText);
|
|
19
|
+
return true;
|
|
20
|
+
}
|