@supernovaio/cli 2.0.39 → 2.0.40
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/dist/code-analyzer/analyzers/component-usage.d.ts +6 -0
- package/dist/code-analyzer/analyzers/component-usage.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/component-usage.js +344 -0
- package/dist/code-analyzer/analyzers/component-usage.js.map +1 -0
- package/dist/code-analyzer/analyzers/helpers.d.ts +11 -0
- package/dist/code-analyzer/analyzers/helpers.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/helpers.js +59 -0
- package/dist/code-analyzer/analyzers/helpers.js.map +1 -0
- package/dist/code-analyzer/analyzers/index.d.ts +8 -0
- package/dist/code-analyzer/analyzers/index.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/index.js +11 -0
- package/dist/code-analyzer/analyzers/index.js.map +1 -0
- package/dist/code-analyzer/analyzers/jsdoc.d.ts +3 -0
- package/dist/code-analyzer/analyzers/jsdoc.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/jsdoc.js +7 -0
- package/dist/code-analyzer/analyzers/jsdoc.js.map +1 -0
- package/dist/code-analyzer/analyzers/static-components.d.ts +3 -0
- package/dist/code-analyzer/analyzers/static-components.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/static-components.js +399 -0
- package/dist/code-analyzer/analyzers/static-components.js.map +1 -0
- package/dist/code-analyzer/analyzers/storybook-docs.d.ts +3 -0
- package/dist/code-analyzer/analyzers/storybook-docs.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/storybook-docs.js +163 -0
- package/dist/code-analyzer/analyzers/storybook-docs.js.map +1 -0
- package/dist/code-analyzer/analyzers/storybook-stories.d.ts +3 -0
- package/dist/code-analyzer/analyzers/storybook-stories.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/storybook-stories.js +91 -0
- package/dist/code-analyzer/analyzers/storybook-stories.js.map +1 -0
- package/dist/code-analyzer/analyzers/types.d.ts +88 -0
- package/dist/code-analyzer/analyzers/types.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/types.js +12 -0
- package/dist/code-analyzer/analyzers/types.js.map +1 -0
- package/dist/code-analyzer/analyzers/typescript-api.d.ts +3 -0
- package/dist/code-analyzer/analyzers/typescript-api.d.ts.map +1 -0
- package/dist/code-analyzer/analyzers/typescript-api.js +7 -0
- package/dist/code-analyzer/analyzers/typescript-api.js.map +1 -0
- package/dist/code-analyzer/components/analyze.d.ts +8 -0
- package/dist/code-analyzer/components/analyze.d.ts.map +1 -0
- package/dist/code-analyzer/components/analyze.js +38 -0
- package/dist/code-analyzer/components/analyze.js.map +1 -0
- package/dist/code-analyzer/components/mappers/component.d.ts +4 -0
- package/dist/code-analyzer/components/mappers/component.d.ts.map +1 -0
- package/dist/code-analyzer/components/mappers/component.js +20 -0
- package/dist/code-analyzer/components/mappers/component.js.map +1 -0
- package/dist/code-analyzer/components/mappers/property.d.ts +4 -0
- package/dist/code-analyzer/components/mappers/property.d.ts.map +1 -0
- package/dist/code-analyzer/components/mappers/property.js +19 -0
- package/dist/code-analyzer/components/mappers/property.js.map +1 -0
- package/dist/code-analyzer/components/parser/index.d.ts +6 -0
- package/dist/code-analyzer/components/parser/index.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/index.js +9 -0
- package/dist/code-analyzer/components/parser/index.js.map +1 -0
- package/dist/code-analyzer/components/parser/module-parser.d.ts +12 -0
- package/dist/code-analyzer/components/parser/module-parser.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/module-parser.js +116 -0
- package/dist/code-analyzer/components/parser/module-parser.js.map +1 -0
- package/dist/code-analyzer/components/parser/parser.d.ts +46 -0
- package/dist/code-analyzer/components/parser/parser.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/parser.js +904 -0
- package/dist/code-analyzer/components/parser/parser.js.map +1 -0
- package/dist/code-analyzer/components/parser/types.d.ts +123 -0
- package/dist/code-analyzer/components/parser/types.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/types.js +21 -0
- package/dist/code-analyzer/components/parser/types.js.map +1 -0
- package/dist/code-analyzer/components/parser/utils/build-filter.d.ts +3 -0
- package/dist/code-analyzer/components/parser/utils/build-filter.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/utils/build-filter.js +31 -0
- package/dist/code-analyzer/components/parser/utils/build-filter.js.map +1 -0
- package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts +3 -0
- package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/utils/filter-duplicates.js +17 -0
- package/dist/code-analyzer/components/parser/utils/filter-duplicates.js.map +1 -0
- package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts +4 -0
- package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/utils/is-react-component.js +43 -0
- package/dist/code-analyzer/components/parser/utils/is-react-component.js.map +1 -0
- package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts +2 -0
- package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts.map +1 -0
- package/dist/code-analyzer/components/parser/utils/trim-file-name.js +22 -0
- package/dist/code-analyzer/components/parser/utils/trim-file-name.js.map +1 -0
- package/dist/code-analyzer/components/types.d.ts +18 -0
- package/dist/code-analyzer/components/types.d.ts.map +1 -0
- package/dist/code-analyzer/components/types.js +5 -0
- package/dist/code-analyzer/components/types.js.map +1 -0
- package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts +2 -0
- package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts.map +1 -0
- package/dist/code-analyzer/components/utils/get-module-exports-path.js +60 -0
- package/dist/code-analyzer/components/utils/get-module-exports-path.js.map +1 -0
- package/dist/code-analyzer/index.d.ts +5 -0
- package/dist/code-analyzer/index.d.ts.map +1 -0
- package/dist/code-analyzer/index.js +8 -0
- package/dist/code-analyzer/index.js.map +1 -0
- package/dist/code-analyzer/orchestrator/index.d.ts +2 -0
- package/dist/code-analyzer/orchestrator/index.d.ts.map +1 -0
- package/dist/code-analyzer/orchestrator/index.js +5 -0
- package/dist/code-analyzer/orchestrator/index.js.map +1 -0
- package/dist/code-analyzer/orchestrator/run-analysis.d.ts +19 -0
- package/dist/code-analyzer/orchestrator/run-analysis.d.ts.map +1 -0
- package/dist/code-analyzer/orchestrator/run-analysis.js +109 -0
- package/dist/code-analyzer/orchestrator/run-analysis.js.map +1 -0
- package/dist/code-analyzer/snapshot/index.d.ts +2 -0
- package/dist/code-analyzer/snapshot/index.d.ts.map +1 -0
- package/dist/code-analyzer/snapshot/index.js +5 -0
- package/dist/code-analyzer/snapshot/index.js.map +1 -0
- package/dist/code-analyzer/snapshot/write-snapshot.d.ts +17 -0
- package/dist/code-analyzer/snapshot/write-snapshot.d.ts.map +1 -0
- package/dist/code-analyzer/snapshot/write-snapshot.js +60 -0
- package/dist/code-analyzer/snapshot/write-snapshot.js.map +1 -0
- package/dist/commands/components-import.js +3 -3
- package/dist/commands/components-import.js.map +1 -1
- package/dist/commands/publish-documentation.d.ts +2 -2
- package/dist/commands/run-local-exporter.js +2 -2
- package/dist/commands/run-local-exporter.js.map +1 -1
- package/dist/commands/storybook-import.d.ts +2 -2
- package/dist/commands/template-upload.d.ts.map +1 -1
- package/dist/commands/template-upload.js +10 -12
- package/dist/commands/template-upload.js.map +1 -1
- package/dist/types/config.d.ts +5 -5
- package/dist/types/types.js +2 -2
- package/dist/types/types.js.map +1 -1
- package/dist/utils/analyze-command.js +3 -3
- package/dist/utils/analyze-command.js.map +1 -1
- package/dist/utils/discover.d.ts +2 -2
- package/dist/utils/discover.d.ts.map +1 -1
- package/dist/utils/discover.js +25 -23
- package/dist/utils/discover.js.map +1 -1
- package/dist/utils/figma-tokens-data-loader.js +2 -2
- package/dist/utils/figma-tokens-data-loader.js.map +1 -1
- package/dist/utils/run-exporter/exporter-utils.js +2 -2
- package/dist/utils/run-exporter/exporter-utils.js.map +1 -1
- package/dist/utils/validate-templates.d.ts +1 -1
- package/dist/utils/validate-templates.d.ts.map +1 -1
- package/dist/utils/validate-templates.js +4 -4
- package/dist/utils/validate-templates.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d6a0a8d6-93f5-5ba0-8222-f2bb5a3c4b4c")}catch(e){}}();
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
function getNodeModulesRoots(rootDir) {
|
|
6
|
+
const roots = [];
|
|
7
|
+
let current = path.resolve(rootDir);
|
|
8
|
+
while (true) {
|
|
9
|
+
roots.push(path.join(current, "node_modules"));
|
|
10
|
+
const parent = path.dirname(current);
|
|
11
|
+
if (parent === current) {
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
current = parent;
|
|
15
|
+
}
|
|
16
|
+
return roots;
|
|
17
|
+
}
|
|
18
|
+
export async function getModuleEntryPath(rootDir, modulePath) {
|
|
19
|
+
let entryFile = null;
|
|
20
|
+
const possibleEntries = [
|
|
21
|
+
path.join(modulePath, "index.ts"),
|
|
22
|
+
path.join(modulePath, "index.mts"),
|
|
23
|
+
path.join(modulePath, "index.mjs"),
|
|
24
|
+
path.join(modulePath, "index.d.ts"),
|
|
25
|
+
path.join(modulePath, "index.d.mts"),
|
|
26
|
+
path.join(modulePath, "dist/index.d.ts"),
|
|
27
|
+
path.join(modulePath, "dist/index.d.mts"),
|
|
28
|
+
path.join(modulePath, "dist/index.mts"),
|
|
29
|
+
path.join(modulePath, "dist/index.mjs"),
|
|
30
|
+
path.join(modulePath, "lib/index.d.ts"),
|
|
31
|
+
path.join(modulePath, "lib/index.d.mts"),
|
|
32
|
+
path.join(modulePath, "index.js"),
|
|
33
|
+
path.join(modulePath, "index.cjs"),
|
|
34
|
+
path.join(modulePath, "dist/index.js"),
|
|
35
|
+
path.join(modulePath, "dist/index.cjs"),
|
|
36
|
+
path.join(modulePath, "lib/index.js"),
|
|
37
|
+
path.join(modulePath, "lib/index.cjs"),
|
|
38
|
+
];
|
|
39
|
+
const nodeModulesRoots = getNodeModulesRoots(rootDir);
|
|
40
|
+
const allPossibleEntriesPaths = [
|
|
41
|
+
...nodeModulesRoots.flatMap(nodeModulesRoot => possibleEntries.map(entry => path.join(nodeModulesRoot, entry))),
|
|
42
|
+
...possibleEntries.map(entry => path.join(rootDir, entry)),
|
|
43
|
+
];
|
|
44
|
+
for (const entryPath of allPossibleEntriesPaths) {
|
|
45
|
+
try {
|
|
46
|
+
await fs.access(entryPath);
|
|
47
|
+
entryFile = entryPath;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!entryFile) {
|
|
55
|
+
throw new Error(`Could not find entry file for "${modulePath}"`);
|
|
56
|
+
}
|
|
57
|
+
return entryFile;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=get-module-exports-path.js.map
|
|
60
|
+
//# debugId=d6a0a8d6-93f5-5ba0-8222-f2bb5a3c4b4c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-module-exports-path.js","sources":["../../../../src/code-analyzer/components/utils/get-module-exports-path.ts"],"sourceRoot":"","sourcesContent":["import * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nfunction getNodeModulesRoots(rootDir: string): string[] {\n const roots: string[] = []\n let current = path.resolve(rootDir)\n\n while (true) {\n roots.push(path.join(current, \"node_modules\"))\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n\n current = parent\n }\n\n return roots\n}\n\nexport async function getModuleEntryPath(rootDir: string, modulePath: string): Promise<string> {\n let entryFile: null | string = null\n\n const possibleEntries = [\n path.join(modulePath, \"index.ts\"),\n path.join(modulePath, \"index.mts\"),\n path.join(modulePath, \"index.mjs\"),\n path.join(modulePath, \"index.d.ts\"),\n path.join(modulePath, \"index.d.mts\"),\n path.join(modulePath, \"dist/index.d.ts\"),\n path.join(modulePath, \"dist/index.d.mts\"),\n path.join(modulePath, \"dist/index.mts\"),\n path.join(modulePath, \"dist/index.mjs\"),\n path.join(modulePath, \"lib/index.d.ts\"),\n path.join(modulePath, \"lib/index.d.mts\"),\n path.join(modulePath, \"index.js\"),\n path.join(modulePath, \"index.cjs\"),\n path.join(modulePath, \"dist/index.js\"),\n path.join(modulePath, \"dist/index.cjs\"),\n path.join(modulePath, \"lib/index.js\"),\n path.join(modulePath, \"lib/index.cjs\"),\n ]\n\n const nodeModulesRoots = getNodeModulesRoots(rootDir)\n const allPossibleEntriesPaths = [\n ...nodeModulesRoots.flatMap(nodeModulesRoot => possibleEntries.map(entry => path.join(nodeModulesRoot, entry))),\n ...possibleEntries.map(entry => path.join(rootDir, entry)),\n ]\n\n for (const entryPath of allPossibleEntriesPaths) {\n try {\n await fs.access(entryPath)\n entryFile = entryPath\n break\n } catch {\n continue\n }\n }\n\n if (!entryFile) {\n throw new Error(`Could not find entry file for \"${modulePath}\"`)\n }\n\n return entryFile\n}\n"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,SAAS,mBAAmB,CAAC,OAAe;IAC1C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAEnC,OAAO,IAAI,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACp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AAG,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACrD,MAAM,uBAAuB,GAAG;QAC9B,GAAG,gBAAgB,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/G,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3D,CAAA;IAED,KAAK,MAAM,SAAS,IAAI,uBAAuB,EAAE,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAC1B,SAAS,GAAG,SAAS,CAAA;YACrB,MAAK;QACP,CAAC;QAAC,MAAM,CAAC;YACP,SAAQ;QACV,CAAC;IACH,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,GAAG,CAAC,CAAA;IAClE,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC","debug_id":"d6a0a8d6-93f5-5ba0-8222-f2bb5a3c4b4c"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-analyzer/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="212bb6c3-8bf9-5063-a704-66e0880dd080")}catch(e){}}();
|
|
3
|
+
export * from "./analyzers/index.js";
|
|
4
|
+
export * from "./components/analyze.js";
|
|
5
|
+
export * from "./orchestrator/index.js";
|
|
6
|
+
export * from "./snapshot/index.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
8
|
+
//# debugId=212bb6c3-8bf9-5063-a704-66e0880dd080
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/code-analyzer/index.ts"],"sourceRoot":"","sourcesContent":["export * from \"./analyzers/index.js\"\nexport * from \"./components/analyze.js\"\nexport * from \"./orchestrator/index.js\"\nexport * from \"./snapshot/index.js\"\n"],"names":[],"mappings":";;AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA","debug_id":"212bb6c3-8bf9-5063-a704-66e0880dd080"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/orchestrator/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="42d0c813-f724-5d47-82ab-04f3876ebc82")}catch(e){}}();
|
|
3
|
+
export * from "./run-analysis.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# debugId=42d0c813-f724-5d47-82ab-04f3876ebc82
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/code-analyzer/orchestrator/index.ts"],"sourceRoot":"","sourcesContent":["export * from \"./run-analysis.js\"\n"],"names":[],"mappings":";;AAAA,cAAc,mBAAmB,CAAA","debug_id":"42d0c813-f724-5d47-82ab-04f3876ebc82"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComponentDescriptor } from "../analyzers/types.js";
|
|
2
|
+
export type AnalyzeProjectInput = {
|
|
3
|
+
designSystemId?: string;
|
|
4
|
+
excludePaths?: string[];
|
|
5
|
+
importFrom: string | string[];
|
|
6
|
+
mode?: "all" | "components" | "usage";
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
snapshotBaseRoot?: string;
|
|
9
|
+
runCommitSha?: string;
|
|
10
|
+
snapshotId?: string;
|
|
11
|
+
versionId?: string;
|
|
12
|
+
};
|
|
13
|
+
export type AnalyzeProjectOutput = {
|
|
14
|
+
components: ComponentDescriptor[];
|
|
15
|
+
snapshotId: string;
|
|
16
|
+
snapshotRoot: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function runCodeAnalysis(input: AnalyzeProjectInput): Promise<AnalyzeProjectOutput>;
|
|
19
|
+
//# sourceMappingURL=run-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-analysis.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/orchestrator/run-analysis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgD,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AASzG,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,YAAY,GAAG,OAAO,CAAA;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAgDD,wBAAsB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA8E/F"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="22fe8582-d0a7-5587-85d0-4e932dfc7f38")}catch(e){}}();
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { analyzeComponentUsage } from "../analyzers/component-usage.js";
|
|
5
|
+
import { analyzeJsDoc } from "../analyzers/jsdoc.js";
|
|
6
|
+
import { analyzeStaticComponents } from "../analyzers/static-components.js";
|
|
7
|
+
import { analyzeStorybookDocs } from "../analyzers/storybook-docs.js";
|
|
8
|
+
import { analyzeStorybookStories } from "../analyzers/storybook-stories.js";
|
|
9
|
+
import { analyzeTypescriptApi } from "../analyzers/typescript-api.js";
|
|
10
|
+
import { writeSnapshot } from "../snapshot/write-snapshot.js";
|
|
11
|
+
function createSnapshotId() {
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const yyyy = now.getUTCFullYear();
|
|
14
|
+
const mm = String(now.getUTCMonth() + 1).padStart(2, "0");
|
|
15
|
+
const dd = String(now.getUTCDate()).padStart(2, "0");
|
|
16
|
+
const hh = String(now.getUTCHours()).padStart(2, "0");
|
|
17
|
+
const mi = String(now.getUTCMinutes()).padStart(2, "0");
|
|
18
|
+
const ss = String(now.getUTCSeconds()).padStart(2, "0");
|
|
19
|
+
const ms = String(now.getUTCMilliseconds()).padStart(3, "0");
|
|
20
|
+
return `snap-${yyyy}${mm}${dd}-${hh}${mi}${ss}${ms}`;
|
|
21
|
+
}
|
|
22
|
+
async function runAnalyzer(name, work) {
|
|
23
|
+
const startedAt = new Date().toISOString();
|
|
24
|
+
const started = Date.now();
|
|
25
|
+
try {
|
|
26
|
+
const output = await work();
|
|
27
|
+
return {
|
|
28
|
+
output,
|
|
29
|
+
run: {
|
|
30
|
+
analyzer: name,
|
|
31
|
+
durationMs: Date.now() - started,
|
|
32
|
+
finishedAt: new Date().toISOString(),
|
|
33
|
+
startedAt,
|
|
34
|
+
status: "done",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
run: {
|
|
41
|
+
analyzer: name,
|
|
42
|
+
durationMs: Date.now() - started,
|
|
43
|
+
finishedAt: new Date().toISOString(),
|
|
44
|
+
message: error instanceof Error ? error.message : String(error),
|
|
45
|
+
startedAt,
|
|
46
|
+
status: "failed",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function runCodeAnalysis(input) {
|
|
52
|
+
const snapshotId = input.snapshotId ?? createSnapshotId();
|
|
53
|
+
const snapshotRoot = path.join(input.snapshotBaseRoot ?? input.projectRoot, ".supernova", "snapshots", snapshotId);
|
|
54
|
+
const excludePaths = input.excludePaths ?? [];
|
|
55
|
+
const mode = input.mode ?? "components";
|
|
56
|
+
const runComponentPipeline = mode === "components" || mode === "all";
|
|
57
|
+
const runUsagePipeline = mode === "usage" || mode === "all";
|
|
58
|
+
const usageImportFromPackages = (Array.isArray(input.importFrom) ? input.importFrom : [input.importFrom])
|
|
59
|
+
.map(item => item.trim())
|
|
60
|
+
.filter(Boolean);
|
|
61
|
+
const artifacts = {
|
|
62
|
+
componentUsage: {},
|
|
63
|
+
jsdoc: {},
|
|
64
|
+
staticComponents: [],
|
|
65
|
+
storybookDocs: {},
|
|
66
|
+
storybookStories: {},
|
|
67
|
+
typescriptApi: {},
|
|
68
|
+
};
|
|
69
|
+
let components = [];
|
|
70
|
+
if (runComponentPipeline) {
|
|
71
|
+
const componentsImportFrom = Array.isArray(input.importFrom) ? input.importFrom[0] : input.importFrom;
|
|
72
|
+
const staticRun = await runAnalyzer("static-components", async () => analyzeStaticComponents(input.projectRoot, componentsImportFrom));
|
|
73
|
+
const staticResult = staticRun.output;
|
|
74
|
+
components = staticResult?.components ?? [];
|
|
75
|
+
artifacts.staticComponents = components;
|
|
76
|
+
const typescriptApiRun = await runAnalyzer("typescript-api", async () => staticResult ? analyzeTypescriptApi(staticResult) : Promise.resolve({}));
|
|
77
|
+
artifacts.typescriptApi = typescriptApiRun.output ?? {};
|
|
78
|
+
const storiesRun = await runAnalyzer("storybook-stories", async () => analyzeStorybookStories(input.projectRoot, components, excludePaths));
|
|
79
|
+
artifacts.storybookStories = storiesRun.output ?? {};
|
|
80
|
+
const docsRun = await runAnalyzer("storybook-docs", async () => analyzeStorybookDocs(input.projectRoot, components, excludePaths));
|
|
81
|
+
artifacts.storybookDocs = docsRun.output ?? {};
|
|
82
|
+
const jsdocRun = await runAnalyzer("jsdoc", async () => staticResult ? analyzeJsDoc(staticResult) : Promise.resolve({}));
|
|
83
|
+
artifacts.jsdoc = jsdocRun.output ?? {};
|
|
84
|
+
}
|
|
85
|
+
if (runUsagePipeline) {
|
|
86
|
+
const usageRun = await runAnalyzer("component-usage", async () => analyzeComponentUsage(input.projectRoot, components, input.importFrom, excludePaths));
|
|
87
|
+
artifacts.componentUsage = usageRun.output?.records ?? {};
|
|
88
|
+
if (components.length === 0 && usageRun.output?.components.length) {
|
|
89
|
+
components = usageRun.output.components;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
await writeSnapshot({
|
|
93
|
+
artifacts,
|
|
94
|
+
rawArtifacts: mode === "usage"
|
|
95
|
+
? ["component-usage"]
|
|
96
|
+
: mode === "components"
|
|
97
|
+
? ["static-components", "typescript-api", "storybook-stories", "storybook-docs", "jsdoc"]
|
|
98
|
+
: ["static-components", "typescript-api", "storybook-stories", "storybook-docs", "jsdoc", "component-usage"],
|
|
99
|
+
snapshotRoot,
|
|
100
|
+
usageImportFromPackages,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
components,
|
|
104
|
+
snapshotId,
|
|
105
|
+
snapshotRoot,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=run-analysis.js.map
|
|
109
|
+
//# debugId=22fe8582-d0a7-5587-85d0-4e932dfc7f38
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-analysis.js","sources":["../../../src/code-analyzer/orchestrator/run-analysis.ts"],"sourceRoot":"","sourcesContent":["import path from \"node:path\"\n\nimport { AnalyzerArtifacts, AnalyzerName, AnalyzerRun, ComponentDescriptor } from \"../analyzers/types.js\"\nimport { analyzeComponentUsage } from \"../analyzers/component-usage.js\"\nimport { analyzeJsDoc } from \"../analyzers/jsdoc.js\"\nimport { analyzeStaticComponents } from \"../analyzers/static-components.js\"\nimport { analyzeStorybookDocs } from \"../analyzers/storybook-docs.js\"\nimport { analyzeStorybookStories } from \"../analyzers/storybook-stories.js\"\nimport { analyzeTypescriptApi } from \"../analyzers/typescript-api.js\"\nimport { writeSnapshot } from \"../snapshot/write-snapshot.js\"\n\nexport type AnalyzeProjectInput = {\n designSystemId?: string\n excludePaths?: string[]\n importFrom: string | string[]\n mode?: \"all\" | \"components\" | \"usage\"\n projectRoot: string\n snapshotBaseRoot?: string\n runCommitSha?: string\n snapshotId?: string\n versionId?: string\n}\n\nexport type AnalyzeProjectOutput = {\n components: ComponentDescriptor[]\n snapshotId: string\n snapshotRoot: string\n}\n\nfunction createSnapshotId(): string {\n const now = new Date()\n const yyyy = now.getUTCFullYear()\n const mm = String(now.getUTCMonth() + 1).padStart(2, \"0\")\n const dd = String(now.getUTCDate()).padStart(2, \"0\")\n const hh = String(now.getUTCHours()).padStart(2, \"0\")\n const mi = String(now.getUTCMinutes()).padStart(2, \"0\")\n const ss = String(now.getUTCSeconds()).padStart(2, \"0\")\n const ms = String(now.getUTCMilliseconds()).padStart(3, \"0\")\n\n return `snap-${yyyy}${mm}${dd}-${hh}${mi}${ss}${ms}`\n}\n\nasync function runAnalyzer<T>(\n name: AnalyzerName,\n work: () => Promise<T>,\n): Promise<{ output?: T; run: AnalyzerRun }> {\n const startedAt = new Date().toISOString()\n const started = Date.now()\n\n try {\n const output = await work()\n return {\n output,\n run: {\n analyzer: name,\n durationMs: Date.now() - started,\n finishedAt: new Date().toISOString(),\n startedAt,\n status: \"done\",\n },\n }\n } catch (error) {\n return {\n run: {\n analyzer: name,\n durationMs: Date.now() - started,\n finishedAt: new Date().toISOString(),\n message: error instanceof Error ? error.message : String(error),\n startedAt,\n status: \"failed\",\n },\n }\n }\n}\n\nexport async function runCodeAnalysis(input: AnalyzeProjectInput): Promise<AnalyzeProjectOutput> {\n const snapshotId = input.snapshotId ?? createSnapshotId()\n const snapshotRoot = path.join(input.snapshotBaseRoot ?? input.projectRoot, \".supernova\", \"snapshots\", snapshotId)\n const excludePaths = input.excludePaths ?? []\n const mode = input.mode ?? \"components\"\n const runComponentPipeline = mode === \"components\" || mode === \"all\"\n const runUsagePipeline = mode === \"usage\" || mode === \"all\"\n const usageImportFromPackages = (Array.isArray(input.importFrom) ? input.importFrom : [input.importFrom])\n .map(item => item.trim())\n .filter(Boolean)\n\n const artifacts: AnalyzerArtifacts = {\n componentUsage: {},\n jsdoc: {},\n staticComponents: [],\n storybookDocs: {},\n storybookStories: {},\n typescriptApi: {},\n }\n let components: ComponentDescriptor[] = []\n\n if (runComponentPipeline) {\n const componentsImportFrom = Array.isArray(input.importFrom) ? input.importFrom[0] : input.importFrom\n const staticRun = await runAnalyzer(\"static-components\", async () =>\n analyzeStaticComponents(input.projectRoot, componentsImportFrom),\n )\n const staticResult = staticRun.output\n components = staticResult?.components ?? []\n artifacts.staticComponents = components\n\n const typescriptApiRun = await runAnalyzer(\"typescript-api\", async () =>\n staticResult ? analyzeTypescriptApi(staticResult) : Promise.resolve({}),\n )\n artifacts.typescriptApi = typescriptApiRun.output ?? {}\n\n const storiesRun = await runAnalyzer(\"storybook-stories\", async () =>\n analyzeStorybookStories(input.projectRoot, components, excludePaths),\n )\n artifacts.storybookStories = storiesRun.output ?? {}\n\n const docsRun = await runAnalyzer(\"storybook-docs\", async () =>\n analyzeStorybookDocs(input.projectRoot, components, excludePaths),\n )\n artifacts.storybookDocs = docsRun.output ?? {}\n\n const jsdocRun = await runAnalyzer(\"jsdoc\", async () =>\n staticResult ? analyzeJsDoc(staticResult) : Promise.resolve({}),\n )\n artifacts.jsdoc = jsdocRun.output ?? {}\n }\n\n if (runUsagePipeline) {\n const usageRun = await runAnalyzer(\"component-usage\", async () =>\n analyzeComponentUsage(input.projectRoot, components, input.importFrom, excludePaths),\n )\n artifacts.componentUsage = usageRun.output?.records ?? {}\n if (components.length === 0 && usageRun.output?.components.length) {\n components = usageRun.output.components\n }\n }\n\n await writeSnapshot({\n artifacts,\n rawArtifacts:\n mode === \"usage\"\n ? [\"component-usage\"]\n : mode === \"components\"\n ? [\"static-components\", \"typescript-api\", \"storybook-stories\", \"storybook-docs\", \"jsdoc\"]\n : [\"static-components\", \"typescript-api\", \"storybook-stories\", \"storybook-docs\", \"jsdoc\", \"component-usage\"],\n snapshotRoot,\n usageImportFromPackages,\n })\n\n return {\n components,\n snapshotId,\n snapshotRoot,\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAA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CAAC,CAAC,iBAAiB,CAAC;YACrB,CAAC,CAAC,IAAI,KAAK,YAAY;gBACrB,CAAC,CAAC,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,OAAO,CAAC;gBACzF,CAAC,CAAC,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,CAAC;QAClH,YAAY;QACZ,uBAAuB;KACxB,CAAC,CAAA;IAEF,OAAO;QACL,UAAU;QACV,UAAU;QACV,YAAY;KACb,CAAA;AACH,CAAC","debug_id":"22fe8582-d0a7-5587-85d0-4e932dfc7f38"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/snapshot/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b1d36602-6dba-5745-9f45-abde550ade2f")}catch(e){}}();
|
|
3
|
+
export * from "./write-snapshot.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# debugId=b1d36602-6dba-5745-9f45-abde550ade2f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/code-analyzer/snapshot/index.ts"],"sourceRoot":"","sourcesContent":["export * from \"./write-snapshot.js\"\n"],"names":[],"mappings":";;AAAA,cAAc,qBAAqB,CAAA","debug_id":"b1d36602-6dba-5745-9f45-abde550ade2f"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnalyzerArtifacts, UsageRecord } from "../analyzers/types.js";
|
|
2
|
+
type Input = {
|
|
3
|
+
artifacts: AnalyzerArtifacts;
|
|
4
|
+
rawArtifacts?: RawArtifactName[];
|
|
5
|
+
snapshotRoot: string;
|
|
6
|
+
usageImportFromPackages?: string[];
|
|
7
|
+
};
|
|
8
|
+
type RawArtifactName = "static-components" | "typescript-api" | "storybook-stories" | "storybook-docs" | "jsdoc" | "component-usage";
|
|
9
|
+
export type ComponentUsageSnapshot = {
|
|
10
|
+
meta: {
|
|
11
|
+
importFromPackages: string[];
|
|
12
|
+
};
|
|
13
|
+
records: Record<string, UsageRecord>;
|
|
14
|
+
};
|
|
15
|
+
export declare function writeSnapshot(input: Input): Promise<void>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=write-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-snapshot.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/snapshot/write-snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEtE,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,iBAAiB,CAAA;IAC5B,YAAY,CAAC,EAAE,eAAe,EAAE,CAAA;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAA;CACnC,CAAA;AAED,KAAK,eAAe,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,OAAO,GACP,iBAAiB,CAAA;AAErB,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QACJ,kBAAkB,EAAE,MAAM,EAAE,CAAA;KAC7B,CAAA;IACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACrC,CAAA;AA8BD,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C/D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6a383449-19a0-5392-ae86-5ab404c62766")}catch(e){}}();
|
|
3
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
async function ensureSnapshotLayout(snapshotRoot) {
|
|
6
|
+
await mkdir(path.join(snapshotRoot, "raw"), { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
function isEmptyJsonPayload(payload) {
|
|
9
|
+
if (payload === null || payload === undefined) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(payload)) {
|
|
13
|
+
return payload.length === 0;
|
|
14
|
+
}
|
|
15
|
+
if (typeof payload === "object") {
|
|
16
|
+
return Object.keys(payload).length === 0;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
async function writeJson(filePath, payload) {
|
|
21
|
+
if (isEmptyJsonPayload(payload)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await writeFile(filePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
25
|
+
}
|
|
26
|
+
export async function writeSnapshot(input) {
|
|
27
|
+
const { artifacts, snapshotRoot } = input;
|
|
28
|
+
await ensureSnapshotLayout(snapshotRoot);
|
|
29
|
+
const rawArtifacts = new Set(input.rawArtifacts ?? ["static-components", "typescript-api", "storybook-stories", "storybook-docs", "jsdoc", "component-usage"]);
|
|
30
|
+
if (rawArtifacts.has("static-components")) {
|
|
31
|
+
await writeJson(path.join(snapshotRoot, "raw", "static-components.json"), artifacts.staticComponents);
|
|
32
|
+
}
|
|
33
|
+
if (rawArtifacts.has("typescript-api")) {
|
|
34
|
+
await writeJson(path.join(snapshotRoot, "raw", "typescript-api.json"), artifacts.typescriptApi);
|
|
35
|
+
}
|
|
36
|
+
if (rawArtifacts.has("storybook-stories")) {
|
|
37
|
+
await writeJson(path.join(snapshotRoot, "raw", "storybook-stories.json"), artifacts.storybookStories);
|
|
38
|
+
}
|
|
39
|
+
if (rawArtifacts.has("storybook-docs")) {
|
|
40
|
+
await writeJson(path.join(snapshotRoot, "raw", "storybook-docs.json"), artifacts.storybookDocs);
|
|
41
|
+
}
|
|
42
|
+
if (rawArtifacts.has("jsdoc")) {
|
|
43
|
+
await writeJson(path.join(snapshotRoot, "raw", "jsdoc.json"), artifacts.jsdoc);
|
|
44
|
+
}
|
|
45
|
+
if (rawArtifacts.has("component-usage")) {
|
|
46
|
+
const usageRecords = artifacts.componentUsage;
|
|
47
|
+
if (isEmptyJsonPayload(usageRecords)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const payload = {
|
|
51
|
+
meta: {
|
|
52
|
+
importFromPackages: [...new Set((input.usageImportFromPackages ?? []).map(item => item.trim()).filter(Boolean))].sort((a, b) => a.localeCompare(b)),
|
|
53
|
+
},
|
|
54
|
+
records: usageRecords,
|
|
55
|
+
};
|
|
56
|
+
await writeJson(path.join(snapshotRoot, "raw", "component-usage.json"), payload);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=write-snapshot.js.map
|
|
60
|
+
//# debugId=6a383449-19a0-5392-ae86-5ab404c62766
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-snapshot.js","sources":["../../../src/code-analyzer/snapshot/write-snapshot.ts"],"sourceRoot":"","sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport { AnalyzerArtifacts, UsageRecord } from \"../analyzers/types.js\"\n\ntype Input = {\n artifacts: AnalyzerArtifacts\n rawArtifacts?: RawArtifactName[]\n snapshotRoot: string\n usageImportFromPackages?: string[]\n}\n\ntype RawArtifactName =\n | \"static-components\"\n | \"typescript-api\"\n | \"storybook-stories\"\n | \"storybook-docs\"\n | \"jsdoc\"\n | \"component-usage\"\n\nexport type ComponentUsageSnapshot = {\n meta: {\n importFromPackages: string[]\n }\n records: Record<string, UsageRecord>\n}\n\nasync function ensureSnapshotLayout(snapshotRoot: string): Promise<void> {\n await mkdir(path.join(snapshotRoot, \"raw\"), { recursive: true })\n}\n\nfunction isEmptyJsonPayload(payload: unknown): boolean {\n if (payload === null || payload === undefined) {\n return true\n }\n\n if (Array.isArray(payload)) {\n return payload.length === 0\n }\n\n if (typeof payload === \"object\") {\n return Object.keys(payload as Record<string, unknown>).length === 0\n }\n\n return false\n}\n\nasync function writeJson(filePath: string, payload: unknown): Promise<void> {\n if (isEmptyJsonPayload(payload)) {\n return\n }\n\n await writeFile(filePath, `${JSON.stringify(payload, null, 2)}\\n`, \"utf8\")\n}\n\nexport async function writeSnapshot(input: Input): Promise<void> {\n const { artifacts, snapshotRoot } = input\n await ensureSnapshotLayout(snapshotRoot)\n\n const rawArtifacts = new Set<RawArtifactName>(\n input.rawArtifacts ?? [\"static-components\", \"typescript-api\", \"storybook-stories\", \"storybook-docs\", \"jsdoc\", \"component-usage\"],\n )\n\n if (rawArtifacts.has(\"static-components\")) {\n await writeJson(path.join(snapshotRoot, \"raw\", \"static-components.json\"), artifacts.staticComponents)\n }\n\n if (rawArtifacts.has(\"typescript-api\")) {\n await writeJson(path.join(snapshotRoot, \"raw\", \"typescript-api.json\"), artifacts.typescriptApi)\n }\n\n if (rawArtifacts.has(\"storybook-stories\")) {\n await writeJson(path.join(snapshotRoot, \"raw\", \"storybook-stories.json\"), artifacts.storybookStories)\n }\n\n if (rawArtifacts.has(\"storybook-docs\")) {\n await writeJson(path.join(snapshotRoot, \"raw\", \"storybook-docs.json\"), artifacts.storybookDocs)\n }\n\n if (rawArtifacts.has(\"jsdoc\")) {\n await writeJson(path.join(snapshotRoot, \"raw\", \"jsdoc.json\"), artifacts.jsdoc)\n }\n\n if (rawArtifacts.has(\"component-usage\")) {\n const usageRecords = artifacts.componentUsage\n if (isEmptyJsonPayload(usageRecords)) {\n return\n }\n\n const payload: ComponentUsageSnapshot = {\n meta: {\n importFromPackages: [...new Set((input.usageImportFromPackages ?? []).map(item => item.trim()).filter(Boolean))].sort(\n (a, b) => a.localeCompare(b),\n ),\n },\n records: usageRecords,\n }\n\n await writeJson(path.join(snapshotRoot, \"raw\", \"component-usage.json\"), payload)\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,IAAI,MAAM,WAAW,CAAA;AA0B5B,KAAK,UAAU,oBAAoB,CAAC,YAAoB;IACtD,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAClE,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,IAAI,CAAC,OAAkC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;IACrE,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAgB;IACzD,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC5E,CAAC;AAED,M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K,EAAE,YAAY,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IAChF,CAAC;IAED,IAAI,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,SAAS,CAAC,cAAc,CAAA;QAC7C,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;YACrC,OAAM;QACR,CAAC;QAED,MAAM,OAAO,GAA2B;YACtC,IAAI,EAAE;gBACJ,kBAAkB,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CACnH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAC7B;aACF;YACD,OAAO,EAAE,YAAY;SACtB,CAAA;QAED,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,sBAAsB,CAAC,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;AACH,CAAC","debug_id":"6a383449-19a0-5392-ae86-5ab404c62766"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ae5b58ad-8f2a-5c93-9f0d-ca24127407f4")}catch(e){}}();
|
|
3
3
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
4
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
5
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
};
|
|
12
12
|
import { Flags } from "@oclif/core";
|
|
13
13
|
import { SentryTraced } from "@sentry/nestjs";
|
|
14
|
-
import { analyzeComponents } from "
|
|
14
|
+
import { analyzeComponents } from "../code-analyzer/components/analyze.js";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { SentryCommand } from "../types/index.js";
|
|
17
17
|
const ImportComponentsConfigSchema = z
|
|
@@ -105,4 +105,4 @@ __decorate([
|
|
|
105
105
|
__metadata("design:returntype", Promise)
|
|
106
106
|
], ImportComponents.prototype, "run", null);
|
|
107
107
|
//# sourceMappingURL=components-import.js.map
|
|
108
|
-
//# debugId=
|
|
108
|
+
//# debugId=ae5b58ad-8f2a-5c93-9f0d-ca24127407f4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-import.js","sources":["../../src/commands/components-import.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { analyzeComponents } from \"
|
|
1
|
+
{"version":3,"file":"components-import.js","sources":["../../src/commands/components-import.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { analyzeComponents } from \"../code-analyzer/components/analyze.js\"\nimport { z, ZodType } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\n\nconst ImportComponentsConfigSchema = z\n .object({\n designSystemId: z.string(),\n importFrom: z.string(),\n rootDir: z.string(),\n versionId: z.string(),\n })\n .transform(data => ({\n ...data,\n rootDir: data.rootDir ?? process.cwd(),\n }))\n\ntype ImportComponentsConfig = z.infer<typeof ImportComponentsConfigSchema>\n\nfunction isComponentsImportDisabled(): boolean {\n return true\n}\n\nexport default class ImportComponents extends SentryCommand<ImportComponentsConfig> {\n static override args = {}\n static override description = \"Analyze react components from given package and import them into Supernova\"\n static override examples = [\n \"<%= config.bin %> <%= command.id %> --importFrom components-package --rootDir ./src\",\n \"<%= config.bin %> <%= command.id %> --importFrom @mui/material\",\n ]\n static override flags = {\n designSystemId: Flags.string({ description: \"Import code components to design system of\", required: true }),\n importFrom: Flags.string({\n char: \"i\",\n description: \"Package or directory path to import components from\",\n required: true,\n }),\n rootDir: Flags.string({\n char: \"r\",\n default: process.cwd(), // Defaults to the current directory\n description:\n \"Root directory of the package where the import should resolve from. Defaults to the current directory\",\n }),\n versionId: Flags.string({ description: \"Import code components to version of\", required: true }),\n }\n static override hidden = true\n\n get commandId(): string {\n return ImportComponents.id\n }\n\n get configSchema(): ZodType<ImportComponentsConfig> {\n return ImportComponentsConfigSchema\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n if (isComponentsImportDisabled()) {\n this.error(\"Command 'components-import' is temporarily disabled. use 'analyze' instead.\")\n }\n\n const { flags } = await this.parse(ImportComponents)\n\n const { designSystemId, importFrom, rootDir, versionId } = flags\n\n this.log(\"📦 Component Import Summary\")\n this.log(\"========================\")\n this.log(`Source: ${importFrom}`)\n this.log(`Root Directory: ${rootDir}`)\n\n const components = await analyzeComponents({ importFrom, rootDir })\n\n if (components.length > 0) {\n this.log(\"\\nComponent Summary Table:\")\n this.log(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\")\n this.log(\"Component Name Props.Num Required Props Names \")\n this.log(\"──────────────────────────────────────────────────────────\")\n\n for (const component of components) {\n const propsCount = Object.keys(component.properties).length\n const requiredCount = Object.values(component.properties).filter(prop => prop.required).length\n const propsNames = new Set(Object.values(component.properties).map(prop => prop.name))\n\n // Format each row with fixed width columns\n const name = component.exportName.padEnd(16, \" \").slice(0, 16)\n const propsNum = String(propsCount).padStart(5, \" \")\n const required = String(requiredCount).padStart(10, \" \")\n const props = [...propsNames].slice(0, 2).join(\", \") + (propsNames.size > 2 ? \", ...\" : \"\")\n\n this.log(`${name} ${propsNum} ${required} ${props}`)\n }\n\n this.log(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\")\n this.log(\"Importing to Supernova...\")\n const client = await this.apiClient()\n const result = await client.designSystems.versions.codeComponents.import(designSystemId, versionId, {\n codeComponents: components.map(c => ({\n ...c,\n persistentId: `${designSystemId}-${versionId}${c.exportName}}`,\n })),\n })\n this.log(`Total: ${result.created} components imported`)\n } else {\n this.log(\"\\n⚠️ No components were imported\")\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,MAAM,4BAA4B,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC;KACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,GAAG,IAAI;IACP,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;CACvC,CAAC,CAAC,CAAA;AAIL,SAAS,0BAA0B;IACjC,OAAO,IAAI,CAAA;A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DocumentationConfigSchema: z.ZodObject<{
|
|
|
8
8
|
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
9
9
|
target: z.ZodString;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
target: string;
|
|
11
12
|
dev: boolean;
|
|
12
13
|
designSystemId: string;
|
|
13
14
|
apiKey: string;
|
|
14
15
|
awaitPublishJob: boolean;
|
|
15
|
-
target: string;
|
|
16
16
|
proxyUrl?: string | undefined;
|
|
17
17
|
}, {
|
|
18
|
+
target: string;
|
|
18
19
|
dev: boolean;
|
|
19
20
|
designSystemId: string;
|
|
20
21
|
apiKey: string;
|
|
21
22
|
awaitPublishJob: boolean;
|
|
22
|
-
target: string;
|
|
23
23
|
proxyUrl?: string | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
type PublishDocumentationConfig = z.infer<typeof PublishDocumentationConfigSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7748230d-2c61-5564-8be1-3d3f1df02a86")}catch(e){}}();
|
|
3
3
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
4
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
5
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -222,4 +222,4 @@ __decorate([
|
|
|
222
222
|
__metadata("design:returntype", Promise)
|
|
223
223
|
], RunLocalExporter.prototype, "writeToBuildPath", null);
|
|
224
224
|
//# sourceMappingURL=run-local-exporter.js.map
|
|
225
|
-
//# debugId=
|
|
225
|
+
//# debugId=7748230d-2c61-5564-8be1-3d3f1df02a86
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-local-exporter.js","sources":["../../src/commands/run-local-exporter.ts"],"sourceRoot":"","sourcesContent":["//\n// run-exporter.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport pulsarCoreTypes from \"@supernova-studio/pulsar-core\"\n// eslint-disable-next-line n/no-extraneous-import\nimport pulsarLanguageTypes from \"@supernova-studio/pulsar-language\"\nimport axios from \"axios\"\nimport * as fs from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport path from \"node:path\"\n// eslint-disable-next-line no-restricted-imports\nimport { z } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\nimport { exportConfiguration } from \"../utils/run-exporter/exporter-utils.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\nconst require = createRequire(import.meta.url)\nconst pulsarCoreProvider = require(\"@supernova-studio/pulsar-core\") as typeof pulsarCoreTypes\nconst pulsarLanguageProvider = require(\"@supernova-studio/pulsar-language\") as typeof pulsarLanguageTypes\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\ninterface RunLocalExporterFlags {\n allowOverridingOutput: boolean\n apiKey: string\n brandId?: string\n designSystemId: string\n exporterDir: string\n outputDir: string\n proxyUrl?: string\n themeId?: string\n}\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that describes the structure of provided design system */\nexport class RunLocalExporter extends SentryCommand<object> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases = [\"run-local-exporter\"]\n // Command help description\n static description = \"Run local exporter package\"\n // Examples how to use the command\n static examples = [\n `$ @supernovaio/cli run-local-exporter \\\n --apiKey=\"[API_KEY]\" \\\n --designSystemId=\"[DESIGN_SYSTEM_ID]\" \\\n --themeId=\"[THEME_ID]\" \\\n --brandId=\"[BRAND_ID]\" \\\n --exporterDir=\"[./path/to/exporter/dir]\" \\\n --outputDir=\"[./path/to/output/dir]\" \\\n --allowOverridingOutput\n `,\n ]\n // Static flags to enable / disable features\n static flags = {\n allowOverridingOutput: Flags.boolean({\n default: false,\n description:\n \"When enabled, CLI will override output in the output directory if same files where present. When disabled, encountering the same file with throw an error.\",\n required: false,\n }),\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n brandId: Flags.string({\n description:\n \"Brand to export. Will only be used when exporter has usesBrands: true, but then it is required to be provided\",\n required: false,\n }),\n designSystemId: Flags.string({ description: \"Design System to export from\", required: true }),\n exporterDir: Flags.string({ description: \"Path to exporter package\", required: true }),\n outputDir: Flags.string({\n description: \"Path to output folder. Must be empty, unless `forceClearOutputDir` is set\",\n required: true,\n }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n themeId: Flags.string({\n description: \"Theme to export. Will only be used when exporter has usesThemes: true, and is optional\",\n required: false,\n }),\n }\n\n get commandId(): string {\n return RunLocalExporter.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n @SentryTraced()\n async executeExporter(\n flags: RunLocalExporterFlags,\n versionId: string,\n ): Promise<{\n logger: pulsarLanguageTypes.PLLogger\n result: Error | pulsarCoreTypes.PCEngineExporterProcessingResult\n success: boolean\n }> {\n // Log engine\n const logger = new pulsarLanguageProvider.PLLogger()\n\n // Initialize pulsar engine and export\n const pulsarEngine = new pulsarCoreProvider.PCPulsar(pulsarCoreTypes.PCPulsarExporterMode.full, logger)\n try {\n // Load pulsar with local URL\n await pulsarEngine.initiateWithLocalFolderURL(flags.exporterDir, pulsarCoreTypes.PCExporterEnvironment.ci)\n\n // Prepare configuration\n const config = exportConfiguration({\n apiKey: flags.apiKey,\n brandId: flags.brandId,\n dsId: flags.designSystemId,\n environment: this.env,\n exportPath: flags.exporterDir,\n logger,\n proxyUrl: flags.proxyUrl,\n themeId: flags.themeId,\n versionId,\n })\n\n // Set logo overrides\n const result = await pulsarEngine.executeExporter(config, false)\n return {\n logger,\n result,\n success: true,\n }\n } catch (error) {\n // Return error\n return {\n logger,\n result: error as Error,\n success: false,\n }\n }\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(RunLocalExporter)\n\n // Execute exporter\n // Get workspace -> design system –> version\n const { version } = await getWritableVersion(flags)\n const result = await this.executeExporter(flags, version.id)\n\n // Log user logs from the execution\n // Note this is currently not used because console.log is directly routed to the stdout and we have no control over it. Pulsar must be updated before this is doable\n if (flags.log) {\n this.logRun(result.logger)\n }\n\n if (result.success) {\n // Write result to output\n await this.writeToBuildPath(result.result as pulsarCoreTypes.PCEngineExporterProcessingResult, flags)\n this.log(\"Export finished successfully\")\n } else {\n // Catch write error\n this.error(`Export failed: ${(result.result as Error).message}`, {\n code: \"ERR_EXPORT_FAILED\",\n })\n }\n }\n\n /** Download file into memory using Axios */\n @SentryTraced()\n private async downloadFileToMemory(fileUrl: string): Promise<Buffer> {\n const response = await axios({\n method: \"get\",\n responseType: \"arraybuffer\",\n url: fileUrl,\n })\n\n return Buffer.from(response.data)\n }\n\n /** Ensure directory exists - if it doesn't create it, recursively */\n @SentryTraced()\n private ensureDirectoryExists(filePath: string, forceLastFragmentIsDirectory: boolean = false) {\n // If the last fragment of path is forced, even paths without / are treated as dirs\n if (forceLastFragmentIsDirectory && !filePath.endsWith(\"/\")) {\n filePath += \"/\"\n }\n\n // Only make directory if it doesn't exist\n if (fs.existsSync(filePath)) {\n return\n }\n\n fs.mkdirSync(filePath, { recursive: true })\n }\n\n /** Log run to output */\n private logRun(logger: pulsarLanguageTypes.PLLogger) {\n for (const log of logger.logs) {\n let message = log.message.trim()\n if (message.startsWith('\"')) {\n message = message.slice(1)\n }\n\n if (message.endsWith('\"')) {\n message = message.slice(0, Math.max(0, message.length - 1))\n }\n\n console.log(`[user]` + message)\n }\n }\n\n @SentryTraced()\n private async writeToBuildPath(\n result: pulsarCoreTypes.PCEngineExporterProcessingResult,\n flags: RunLocalExporterFlags,\n ) {\n // Create build directory if it doesn't exist, otherwise keep as it is. It should never be deleted!\n if (!fs.existsSync(flags.outputDir)) {\n this.ensureDirectoryExists(flags.outputDir)\n }\n\n // If overriding is disabled, test every possible file and if it exists, throw an error\n if (!flags.allowOverridingOutput) {\n for (const file of result.emittedFiles) {\n const destination = path.join(flags.outputDir, file.path)\n if (fs.existsSync(destination)) {\n throw new Error(\n `Exporter produced file for destination ${destination} but that file already exists. Enable --allowOverridingOutput option to allow overriding`,\n )\n }\n }\n }\n\n // Temporary structure to hold file contents\n const filesToWrite: { content: Buffer | string; filePath: string }[] = []\n\n // Function to process a single file\n const processFile = async (file: pulsarCoreTypes.PCEngineFileDescriptor) => {\n const filePath = path.join(flags.outputDir, ...file.path.split(\"/\"))\n const fileDirectory = path.dirname(filePath)\n this.ensureDirectoryExists(fileDirectory)\n\n switch (file.type) {\n case \"copy_file\": {\n const fileContent = fs.readFileSync(file.content)\n filesToWrite.push({ content: fileContent, filePath })\n\n break\n }\n\n case \"copy_file_remote\": {\n const fileContent = await this.downloadFileToMemory(file.content)\n filesToWrite.push({ content: fileContent, filePath })\n\n break\n }\n\n case \"string\": {\n filesToWrite.push({ content: file.content, filePath })\n\n break\n }\n // No default\n }\n }\n\n // Process all files in chunks to speed up the process\n const chunkSize = 4\n for (let i = 0; i < result.emittedFiles.length; i += chunkSize) {\n const chunk = result.emittedFiles.slice(i, i + chunkSize)\n await Promise.all(chunk.map(file => processFile(file)))\n }\n\n // Write all files from the temporary structure to the filesystem as a final step - this is to avoid partial writes\n for (const { content, filePath } of filesToWrite) {\n fs.writeFileSync(filePath, content)\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAG3D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,kBAAkB,GAAG,OAAO,CAAC,+BAA+B,CAA2B,CAAA;AAC7F,MAAM,sBAAsB,GAAG,OAAO,CAAC,mCAAmC,CAA+B,CAAA;AAuBzG,MAAM,OAAO,gBAAiB,SAAQ,aAAqB;IAKzD,MAAM,CAAC,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAEvC,MAAM,CAAC,WAAW,GAAG,4BAA4B,CAA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;QAGD,KAAK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;YACjD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;;AAxLK;IADL,YAAY,EAAE;;;;uDA8Cd;AAGK;IADL,YAAY,EAAE;;;;2CAyBd;AAIa;IADb,YAAY,EAAE;;;;4DASd;AAIO;IADP,YAAY,EAAE;;;;6DAad;AAmBa;IADb,YAAY,EAAE;;;;wDAkEd","debug_id":"6527a13c-6053-52be-afab-5c291afa6669"}
|
|
1
|
+
{"version":3,"file":"run-local-exporter.js","sources":["../../src/commands/run-local-exporter.ts"],"sourceRoot":"","sourcesContent":["//\n// run-exporter.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport pulsarCoreTypes from \"@supernova-studio/pulsar-core\"\n \nimport pulsarLanguageTypes from \"@supernova-studio/pulsar-language\"\nimport axios from \"axios\"\nimport * as fs from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport path from \"node:path\"\n \nimport { z } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\nimport { exportConfiguration } from \"../utils/run-exporter/exporter-utils.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\nconst require = createRequire(import.meta.url)\nconst pulsarCoreProvider = require(\"@supernova-studio/pulsar-core\") as typeof pulsarCoreTypes\nconst pulsarLanguageProvider = require(\"@supernova-studio/pulsar-language\") as typeof pulsarLanguageTypes\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\ninterface RunLocalExporterFlags {\n allowOverridingOutput: boolean\n apiKey: string\n brandId?: string\n designSystemId: string\n exporterDir: string\n outputDir: string\n proxyUrl?: string\n themeId?: string\n}\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that describes the structure of provided design system */\nexport class RunLocalExporter extends SentryCommand<object> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases = [\"run-local-exporter\"]\n // Command help description\n static description = \"Run local exporter package\"\n // Examples how to use the command\n static examples = [\n `$ @supernovaio/cli run-local-exporter \\\n --apiKey=\"[API_KEY]\" \\\n --designSystemId=\"[DESIGN_SYSTEM_ID]\" \\\n --themeId=\"[THEME_ID]\" \\\n --brandId=\"[BRAND_ID]\" \\\n --exporterDir=\"[./path/to/exporter/dir]\" \\\n --outputDir=\"[./path/to/output/dir]\" \\\n --allowOverridingOutput\n `,\n ]\n // Static flags to enable / disable features\n static flags = {\n allowOverridingOutput: Flags.boolean({\n default: false,\n description:\n \"When enabled, CLI will override output in the output directory if same files where present. When disabled, encountering the same file with throw an error.\",\n required: false,\n }),\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n brandId: Flags.string({\n description:\n \"Brand to export. Will only be used when exporter has usesBrands: true, but then it is required to be provided\",\n required: false,\n }),\n designSystemId: Flags.string({ description: \"Design System to export from\", required: true }),\n exporterDir: Flags.string({ description: \"Path to exporter package\", required: true }),\n outputDir: Flags.string({\n description: \"Path to output folder. Must be empty, unless `forceClearOutputDir` is set\",\n required: true,\n }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n themeId: Flags.string({\n description: \"Theme to export. Will only be used when exporter has usesThemes: true, and is optional\",\n required: false,\n }),\n }\n\n get commandId(): string {\n return RunLocalExporter.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n @SentryTraced()\n async executeExporter(\n flags: RunLocalExporterFlags,\n versionId: string,\n ): Promise<{\n logger: pulsarLanguageTypes.PLLogger\n result: Error | pulsarCoreTypes.PCEngineExporterProcessingResult\n success: boolean\n }> {\n // Log engine\n const logger = new pulsarLanguageProvider.PLLogger()\n\n // Initialize pulsar engine and export\n const pulsarEngine = new pulsarCoreProvider.PCPulsar(pulsarCoreTypes.PCPulsarExporterMode.full, logger)\n try {\n // Load pulsar with local URL\n await pulsarEngine.initiateWithLocalFolderURL(flags.exporterDir, pulsarCoreTypes.PCExporterEnvironment.ci)\n\n // Prepare configuration\n const config = exportConfiguration({\n apiKey: flags.apiKey,\n brandId: flags.brandId,\n dsId: flags.designSystemId,\n environment: this.env,\n exportPath: flags.exporterDir,\n logger,\n proxyUrl: flags.proxyUrl,\n themeId: flags.themeId,\n versionId,\n })\n\n // Set logo overrides\n const result = await pulsarEngine.executeExporter(config, false)\n return {\n logger,\n result,\n success: true,\n }\n } catch (error) {\n // Return error\n return {\n logger,\n result: error as Error,\n success: false,\n }\n }\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(RunLocalExporter)\n\n // Execute exporter\n // Get workspace -> design system –> version\n const { version } = await getWritableVersion(flags)\n const result = await this.executeExporter(flags, version.id)\n\n // Log user logs from the execution\n // Note this is currently not used because console.log is directly routed to the stdout and we have no control over it. Pulsar must be updated before this is doable\n if (flags.log) {\n this.logRun(result.logger)\n }\n\n if (result.success) {\n // Write result to output\n await this.writeToBuildPath(result.result as pulsarCoreTypes.PCEngineExporterProcessingResult, flags)\n this.log(\"Export finished successfully\")\n } else {\n // Catch write error\n this.error(`Export failed: ${(result.result as Error).message}`, {\n code: \"ERR_EXPORT_FAILED\",\n })\n }\n }\n\n /** Download file into memory using Axios */\n @SentryTraced()\n private async downloadFileToMemory(fileUrl: string): Promise<Buffer> {\n const response = await axios({\n method: \"get\",\n responseType: \"arraybuffer\",\n url: fileUrl,\n })\n\n return Buffer.from(response.data)\n }\n\n /** Ensure directory exists - if it doesn't create it, recursively */\n @SentryTraced()\n private ensureDirectoryExists(filePath: string, forceLastFragmentIsDirectory: boolean = false) {\n // If the last fragment of path is forced, even paths without / are treated as dirs\n if (forceLastFragmentIsDirectory && !filePath.endsWith(\"/\")) {\n filePath += \"/\"\n }\n\n // Only make directory if it doesn't exist\n if (fs.existsSync(filePath)) {\n return\n }\n\n fs.mkdirSync(filePath, { recursive: true })\n }\n\n /** Log run to output */\n private logRun(logger: pulsarLanguageTypes.PLLogger) {\n for (const log of logger.logs) {\n let message = log.message.trim()\n if (message.startsWith('\"')) {\n message = message.slice(1)\n }\n\n if (message.endsWith('\"')) {\n message = message.slice(0, Math.max(0, message.length - 1))\n }\n\n console.log(`[user]` + message)\n }\n }\n\n @SentryTraced()\n private async writeToBuildPath(\n result: pulsarCoreTypes.PCEngineExporterProcessingResult,\n flags: RunLocalExporterFlags,\n ) {\n // Create build directory if it doesn't exist, otherwise keep as it is. It should never be deleted!\n if (!fs.existsSync(flags.outputDir)) {\n this.ensureDirectoryExists(flags.outputDir)\n }\n\n // If overriding is disabled, test every possible file and if it exists, throw an error\n if (!flags.allowOverridingOutput) {\n for (const file of result.emittedFiles) {\n const destination = path.join(flags.outputDir, file.path)\n if (fs.existsSync(destination)) {\n throw new Error(\n `Exporter produced file for destination ${destination} but that file already exists. Enable --allowOverridingOutput option to allow overriding`,\n )\n }\n }\n }\n\n // Temporary structure to hold file contents\n const filesToWrite: { content: Buffer | string; filePath: string }[] = []\n\n // Function to process a single file\n const processFile = async (file: pulsarCoreTypes.PCEngineFileDescriptor) => {\n const filePath = path.join(flags.outputDir, ...file.path.split(\"/\"))\n const fileDirectory = path.dirname(filePath)\n this.ensureDirectoryExists(fileDirectory)\n\n switch (file.type) {\n case \"copy_file\": {\n const fileContent = fs.readFileSync(file.content)\n filesToWrite.push({ content: fileContent, filePath })\n\n break\n }\n\n case \"copy_file_remote\": {\n const fileContent = await this.downloadFileToMemory(file.content)\n filesToWrite.push({ content: fileContent, filePath })\n\n break\n }\n\n case \"string\": {\n filesToWrite.push({ content: file.content, filePath })\n\n break\n }\n // No default\n }\n }\n\n // Process all files in chunks to speed up the process\n const chunkSize = 4\n for (let i = 0; i < result.emittedFiles.length; i += chunkSize) {\n const chunk = result.emittedFiles.slice(i, i + chunkSize)\n await Promise.all(chunk.map(file => processFile(file)))\n }\n\n // Write all files from the temporary structure to the filesystem as a final step - this is to avoid partial writes\n for (const { content, filePath } of filesToWrite) {\n fs.writeFileSync(filePath, content)\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAG3D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,kBAAkB,GAAG,OAAO,CAAC,+BAA+B,CAA2B,CAAA;AAC7F,MAAM,sBAAsB,GAAG,OAAO,CAAC,mCAAmC,CAA+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AS,CAAC,CAAA;YACzD,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACzD,CAAC;QAGD,KAAK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;YACjD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;;AAxLK;IADL,YAAY,EAAE;;;;uDA8Cd;AAGK;IADL,YAAY,EAAE;;;;2CAyBd;AAIa;IADb,YAAY,EAAE;;;;4DASd;AAIO;IADP,YAAY,EAAE;;;;6DAad;AAmBa;IADb,YAAY,EAAE;;;;wDAkEd","debug_id":"7748230d-2c61-5564-8be1-3d3f1df02a86"}
|
|
@@ -8,17 +8,17 @@ declare const ImportStorybookConfig: z.ZodObject<{
|
|
|
8
8
|
sourceId: z.ZodOptional<z.ZodString>;
|
|
9
9
|
publicAccess: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name?: string | undefined;
|
|
11
12
|
designSystemId?: string | undefined;
|
|
12
13
|
sourceId?: string | undefined;
|
|
13
14
|
brandId?: string | undefined;
|
|
14
|
-
name?: string | undefined;
|
|
15
15
|
from?: string | undefined;
|
|
16
16
|
publicAccess?: boolean | undefined;
|
|
17
17
|
}, {
|
|
18
|
+
name?: string | undefined;
|
|
18
19
|
designSystemId?: string | undefined;
|
|
19
20
|
sourceId?: string | undefined;
|
|
20
21
|
brandId?: string | undefined;
|
|
21
|
-
name?: string | undefined;
|
|
22
22
|
from?: string | undefined;
|
|
23
23
|
publicAccess?: boolean | undefined;
|
|
24
24
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,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