@ng-prism/core 21.10.1 → 21.10.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"prism-pipeline.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/prism-pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;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,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;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,CAmD9B"}
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;AAMhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;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,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;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,CAoD9B"}
@@ -1,5 +1,5 @@
1
1
  import { join, dirname } from 'path';
2
- import { writeFileSync, readFileSync, mkdirSync, statSync, renameSync, existsSync, unlinkSync } from 'fs';
2
+ import { writeFileSync, readFileSync, mkdirSync, statSync, renameSync, existsSync, unlinkSync, } from 'fs';
3
3
  import ts from 'typescript';
4
4
  import { createScanner } from '../scanner/scanner.js';
5
5
  import { discoverSecondaryEntryPoints } from '../scanner/entry-point-discovery.js';
@@ -28,8 +28,8 @@ export async function runPrismPipeline(options, context, state) {
28
28
  pages: manifest.pages,
29
29
  });
30
30
  const projectMeta = await context.getProjectMetadata(options.prismProject);
31
- const sourceRoot = projectMeta['sourceRoot']
32
- ?? join('projects', options.prismProject, 'src');
31
+ const sourceRoot = projectMeta['sourceRoot'] ??
32
+ join('projects', options.prismProject, 'src');
33
33
  const manifestPath = join(workspaceRoot, sourceRoot, 'prism-manifest.ts');
34
34
  mkdirSync(join(workspaceRoot, sourceRoot), { recursive: true });
35
35
  const written = writeManifestIfChanged(manifestPath, source);
@@ -63,7 +63,9 @@ function writeManifestIfChanged(manifestPath, newContent) {
63
63
  try {
64
64
  unlinkSync(tempPath);
65
65
  }
66
- catch { /* best-effort cleanup */ }
66
+ catch {
67
+ /* best-effort cleanup */
68
+ }
67
69
  }
68
70
  throw err;
69
71
  }
@@ -77,6 +79,18 @@ function isDirectory(path) {
77
79
  return false;
78
80
  }
79
81
  }
82
+ function findLibraryRoot(filePath) {
83
+ let dir = dirname(filePath);
84
+ let parent = dirname(dir);
85
+ while (dir !== parent) {
86
+ if (existsSync(join(dir, 'ng-package.json'))) {
87
+ return dir;
88
+ }
89
+ dir = parent;
90
+ parent = dirname(dir);
91
+ }
92
+ return undefined;
93
+ }
80
94
  function resolveTsconfigPaths(entryPointDir) {
81
95
  const configPath = ts.findConfigFile(entryPointDir, ts.sys.fileExists, 'tsconfig.json');
82
96
  if (!configPath)
@@ -95,10 +109,17 @@ function resolveTsconfigPaths(entryPointDir) {
95
109
  function scanEntryPoints(workspaceRoot, options, state) {
96
110
  const absoluteEntryPoint = join(workspaceRoot, options.entryPoint);
97
111
  const pathOptions = resolveTsconfigPaths(dirname(absoluteEntryPoint));
98
- if (!isDirectory(absoluteEntryPoint)) {
112
+ const entryIsDirectory = isDirectory(absoluteEntryPoint);
113
+ const libraryRoot = entryIsDirectory
114
+ ? absoluteEntryPoint
115
+ : findLibraryRoot(absoluteEntryPoint);
116
+ if (!libraryRoot) {
117
+ return getOrCreateScanner(state, absoluteEntryPoint, pathOptions).scan();
118
+ }
119
+ const entryPoints = discoverSecondaryEntryPoints(libraryRoot, options.libraryImportPath);
120
+ if (entryPoints.length === 0 && !entryIsDirectory) {
99
121
  return getOrCreateScanner(state, absoluteEntryPoint, pathOptions).scan();
100
122
  }
101
- const entryPoints = discoverSecondaryEntryPoints(absoluteEntryPoint, options.libraryImportPath);
102
123
  const allComponents = [];
103
124
  for (const ep of entryPoints) {
104
125
  const scanner = getOrCreateScanner(state, ep.entryFile, pathOptions);
@@ -141,8 +141,7 @@ function addBuilderTargets(options) {
141
141
  const project = workspace.projects[options.project];
142
142
  const prismProjectName = `${options.project}-prism`;
143
143
  const port = options.port ?? 4400;
144
- const sourceRoot = project.sourceRoot ?? `${project.root}/src`;
145
- const entryPoint = `${sourceRoot}/public-api.ts`;
144
+ const entryPoint = project.root ?? project.sourceRoot ?? `projects/${options.project}`;
146
145
  if (!project.architect) {
147
146
  project.architect = {};
148
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-prism/core",
3
- "version": "21.10.1",
3
+ "version": "21.10.2",
4
4
  "description": "ng-prism — the Angular-native Storybook alternative. Lightweight component showcase with @Showcase decorator, no story files needed.",
5
5
  "keywords": [
6
6
  "ng-prism",