@ikas/component-cli 1.4.0-beta.153 → 1.4.0-beta.155
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/build-tools.d.ts +18 -0
- package/dist/build-tools.d.ts.map +1 -1
- package/dist/build-tools.js +18 -0
- package/dist/build-tools.js.map +1 -1
- package/dist/commands/create.d.ts +4 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +176 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/list-page-sections.d.ts.map +1 -1
- package/dist/commands/list-page-sections.js +8 -2
- package/dist/commands/list-page-sections.js.map +1 -1
- package/dist/commands/move-page-section.d.ts.map +1 -1
- package/dist/commands/move-page-section.js +5 -1
- package/dist/commands/move-page-section.js.map +1 -1
- package/dist/utils/__tests__/detect-theme-global-name-lookup.test.d.ts +2 -0
- package/dist/utils/__tests__/detect-theme-global-name-lookup.test.d.ts.map +1 -0
- package/dist/utils/__tests__/detect-theme-global-name-lookup.test.js +83 -0
- package/dist/utils/__tests__/detect-theme-global-name-lookup.test.js.map +1 -0
- package/dist/utils/detect-theme-global-name-lookup.d.ts +38 -0
- package/dist/utils/detect-theme-global-name-lookup.d.ts.map +1 -0
- package/dist/utils/detect-theme-global-name-lookup.js +173 -0
- package/dist/utils/detect-theme-global-name-lookup.js.map +1 -0
- package/package.json +5 -2
package/dist/build-tools.d.ts
CHANGED
|
@@ -5,7 +5,25 @@
|
|
|
5
5
|
* (e.g. @ikas/builtin-components' generate script) can import them from a stable
|
|
6
6
|
* package subpath instead of reaching into ./utils internals. Exposed via the
|
|
7
7
|
* "./build-tools" entry in this package's "exports" map.
|
|
8
|
+
*
|
|
9
|
+
* That entry resolves to ./dist, not ./src — `files` only ships dist/bin/templates, so a
|
|
10
|
+
* src-pointing export works via the workspace symlink but is ENOENT for anyone installing
|
|
11
|
+
* from npm. Consequence for in-repo consumers: this package must be BUILT before its
|
|
12
|
+
* build-tools can be imported (see the `generate` task in turbo.json).
|
|
8
13
|
*/
|
|
9
14
|
export { compileAllComponents } from "./utils/compile.js";
|
|
10
15
|
export { buildChunkMapping, transformChunkForCanvas, transformEsmToWindowGlobals } from "./utils/esm-transform.js";
|
|
16
|
+
/**
|
|
17
|
+
* What a prop type means in TypeScript — the table `generateTypesFile` writes a component's
|
|
18
|
+
* types.ts from. Exported because @ikas/builtin-components generates the same file for the
|
|
19
|
+
* built-in components and has to produce byte-identical output; before this it kept a copy,
|
|
20
|
+
* and a copy of this table is a silently wrong prop type in every component it describes.
|
|
21
|
+
*
|
|
22
|
+
* Note that `@ikas/editor-models` exports a third variant of the same mapping
|
|
23
|
+
* (`PropTypeToTSType`) which does NOT agree with this one — it maps COMPONENT to
|
|
24
|
+
* `ComponentChild` rather than `any` and carries RAFFLE/FUNCTION entries this table lacks.
|
|
25
|
+
* This one is authoritative for anything emitting a component's types.ts, because it is the
|
|
26
|
+
* one the CLI itself writes with.
|
|
27
|
+
*/
|
|
28
|
+
export { PROP_TYPE_TO_TS } from "./utils/component-helpers.js";
|
|
11
29
|
//# sourceMappingURL=build-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-tools.d.ts","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"build-tools.d.ts","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACnH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/build-tools.js
CHANGED
|
@@ -5,7 +5,25 @@
|
|
|
5
5
|
* (e.g. @ikas/builtin-components' generate script) can import them from a stable
|
|
6
6
|
* package subpath instead of reaching into ./utils internals. Exposed via the
|
|
7
7
|
* "./build-tools" entry in this package's "exports" map.
|
|
8
|
+
*
|
|
9
|
+
* That entry resolves to ./dist, not ./src — `files` only ships dist/bin/templates, so a
|
|
10
|
+
* src-pointing export works via the workspace symlink but is ENOENT for anyone installing
|
|
11
|
+
* from npm. Consequence for in-repo consumers: this package must be BUILT before its
|
|
12
|
+
* build-tools can be imported (see the `generate` task in turbo.json).
|
|
8
13
|
*/
|
|
9
14
|
export { compileAllComponents } from "./utils/compile.js";
|
|
10
15
|
export { buildChunkMapping, transformChunkForCanvas, transformEsmToWindowGlobals } from "./utils/esm-transform.js";
|
|
16
|
+
/**
|
|
17
|
+
* What a prop type means in TypeScript — the table `generateTypesFile` writes a component's
|
|
18
|
+
* types.ts from. Exported because @ikas/builtin-components generates the same file for the
|
|
19
|
+
* built-in components and has to produce byte-identical output; before this it kept a copy,
|
|
20
|
+
* and a copy of this table is a silently wrong prop type in every component it describes.
|
|
21
|
+
*
|
|
22
|
+
* Note that `@ikas/editor-models` exports a third variant of the same mapping
|
|
23
|
+
* (`PropTypeToTSType`) which does NOT agree with this one — it maps COMPONENT to
|
|
24
|
+
* `ComponentChild` rather than `any` and carries RAFFLE/FUNCTION entries this table lacks.
|
|
25
|
+
* This one is authoritative for anything emitting a component's types.ts, because it is the
|
|
26
|
+
* one the CLI itself writes with.
|
|
27
|
+
*/
|
|
28
|
+
export { PROP_TYPE_TO_TS } from "./utils/component-helpers.js";
|
|
11
29
|
//# sourceMappingURL=build-tools.js.map
|
package/dist/build-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-tools.js","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"build-tools.js","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACnH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4IpC,wBAAgB,mBAAmB,IAAI,OAAO,CA4B7C;AAGD,wBAAsB,GAAG,kBAiCxB"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import { generateComponentId, generateProjectId } from "../utils/component-helpers.js";
|
|
8
|
+
import { readTemplate } from "../utils/template.js";
|
|
9
|
+
const PROP_TYPES = [
|
|
10
|
+
"TEXT",
|
|
11
|
+
"NUMBER",
|
|
12
|
+
"BOOLEAN",
|
|
13
|
+
"IMAGE",
|
|
14
|
+
"LINK",
|
|
15
|
+
"LIST_OF_LINK",
|
|
16
|
+
"COLOR",
|
|
17
|
+
"PRODUCT",
|
|
18
|
+
"PRODUCT_LIST",
|
|
19
|
+
"CATEGORY",
|
|
20
|
+
"CATEGORY_LIST",
|
|
21
|
+
"BRAND",
|
|
22
|
+
"BRAND_LIST",
|
|
23
|
+
"BLOG",
|
|
24
|
+
"BLOG_LIST",
|
|
25
|
+
"BLOG_CATEGORY",
|
|
26
|
+
"BLOG_CATEGORY_LIST",
|
|
27
|
+
"TYPE",
|
|
28
|
+
"ENUM",
|
|
29
|
+
"COMPONENT",
|
|
30
|
+
"COMPONENT_LIST",
|
|
31
|
+
];
|
|
32
|
+
async function createProject(projectName) {
|
|
33
|
+
const spinner = ora("Creating project...").start();
|
|
34
|
+
try {
|
|
35
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
36
|
+
// Check if directory exists
|
|
37
|
+
if (fs.existsSync(projectPath)) {
|
|
38
|
+
spinner.fail(`Directory "${projectName}" already exists`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
// Create directory structure
|
|
42
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
|
43
|
+
fs.mkdirSync(path.join(projectPath, "src/components/ExampleComponent"), { recursive: true });
|
|
44
|
+
fs.mkdirSync(path.join(projectPath, "src/components/ExampleSection"), { recursive: true });
|
|
45
|
+
// Generate IDs for the example config
|
|
46
|
+
const projectId = generateProjectId();
|
|
47
|
+
const exampleComponentId = generateComponentId(projectId, "example-component");
|
|
48
|
+
const exampleSectionId = generateComponentId(projectId, "example-section");
|
|
49
|
+
const vars = {
|
|
50
|
+
PROJECT_NAME: projectName,
|
|
51
|
+
PROJECT_ID: projectId,
|
|
52
|
+
EXAMPLE_COMPONENT_ID: exampleComponentId,
|
|
53
|
+
EXAMPLE_SECTION_ID: exampleSectionId,
|
|
54
|
+
};
|
|
55
|
+
// Write all template files
|
|
56
|
+
const files = [
|
|
57
|
+
{ template: "create/package.json", dest: "package.json", vars },
|
|
58
|
+
{ template: "create/tsconfig.json", dest: "tsconfig.json" },
|
|
59
|
+
{ template: "create/vite.config.ts", dest: "vite.config.ts" },
|
|
60
|
+
{ template: "create/ikas.config.json", dest: "ikas.config.json", vars },
|
|
61
|
+
{ template: "create/gitignore", dest: ".gitignore" },
|
|
62
|
+
{ template: "create/mcp.json", dest: ".mcp.json" },
|
|
63
|
+
{ template: "create/README.md", dest: "README.md", vars },
|
|
64
|
+
{ template: "create/claude-md", dest: "CLAUDE.md" },
|
|
65
|
+
{ template: "create/cursorrules", dest: ".cursorrules" },
|
|
66
|
+
{ template: "create/src/global.css", dest: "src/global.css" },
|
|
67
|
+
{ template: "create/src/global-types.ts", dest: "src/global-types.ts" },
|
|
68
|
+
{ template: "create/src/ikas-component-utils.d.ts", dest: "src/ikas-component-utils.d.ts" },
|
|
69
|
+
{ template: "create/src/components/index.ts", dest: "src/components/index.ts" },
|
|
70
|
+
{ template: "create/src/components/ExampleComponent/index.tsx", dest: "src/components/ExampleComponent/index.tsx" },
|
|
71
|
+
{ template: "create/src/components/ExampleComponent/types.ts", dest: "src/components/ExampleComponent/types.ts" },
|
|
72
|
+
{ template: "create/src/components/ExampleComponent/styles.css", dest: "src/components/ExampleComponent/styles.css" },
|
|
73
|
+
{ template: "create/src/components/ExampleSection/index.tsx", dest: "src/components/ExampleSection/index.tsx" },
|
|
74
|
+
{ template: "create/src/components/ExampleSection/types.ts", dest: "src/components/ExampleSection/types.ts" },
|
|
75
|
+
{ template: "create/src/components/ExampleSection/styles.css", dest: "src/components/ExampleSection/styles.css" },
|
|
76
|
+
];
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
fs.writeFileSync(path.join(projectPath, file.dest), readTemplate(file.template, file.vars));
|
|
79
|
+
}
|
|
80
|
+
// Create or merge .cursor/mcp.json for Cursor editor
|
|
81
|
+
// Uses node + ${workspaceFolder} instead of npx because Cursor
|
|
82
|
+
// doesn't reliably inherit the shell PATH.
|
|
83
|
+
const cursorDir = path.join(projectPath, ".cursor");
|
|
84
|
+
const cursorMcpPath = path.join(cursorDir, "mcp.json");
|
|
85
|
+
fs.mkdirSync(cursorDir, { recursive: true });
|
|
86
|
+
let cursorMcpConfig = { mcpServers: {} };
|
|
87
|
+
if (fs.existsSync(cursorMcpPath)) {
|
|
88
|
+
try {
|
|
89
|
+
cursorMcpConfig = JSON.parse(fs.readFileSync(cursorMcpPath, "utf-8"));
|
|
90
|
+
if (!cursorMcpConfig.mcpServers) {
|
|
91
|
+
cursorMcpConfig.mcpServers = {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
cursorMcpConfig = { mcpServers: {} };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
cursorMcpConfig.mcpServers["ikas-code-components"] = {
|
|
99
|
+
command: "node",
|
|
100
|
+
args: ["${workspaceFolder}/node_modules/@ikas/code-components-mcp/dist/index.js"]
|
|
101
|
+
};
|
|
102
|
+
fs.writeFileSync(cursorMcpPath, JSON.stringify(cursorMcpConfig, null, 2));
|
|
103
|
+
spinner.succeed(chalk.green(`Project "${projectName}" created successfully!`));
|
|
104
|
+
console.log("\n" + chalk.cyan("Next steps:"));
|
|
105
|
+
console.log(chalk.white(` cd ${projectName}`));
|
|
106
|
+
console.log(chalk.white(" npm install"));
|
|
107
|
+
console.log(chalk.white(" npm run dev"));
|
|
108
|
+
console.log("\n" + chalk.gray("Happy coding! 🚀"));
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
spinner.fail("Failed to create project");
|
|
112
|
+
console.error(error);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export function createCreateCommand() {
|
|
117
|
+
return new Command("create")
|
|
118
|
+
.description("Create a new ikas component project")
|
|
119
|
+
.argument("[name]", "Project name")
|
|
120
|
+
.action(async (name) => {
|
|
121
|
+
let projectName = name;
|
|
122
|
+
if (!projectName) {
|
|
123
|
+
const answers = await inquirer.prompt([
|
|
124
|
+
{
|
|
125
|
+
type: "input",
|
|
126
|
+
name: "projectName",
|
|
127
|
+
message: "What is your project name?",
|
|
128
|
+
default: "my-ikas-components",
|
|
129
|
+
validate: (input) => {
|
|
130
|
+
if (!input.trim())
|
|
131
|
+
return "Project name is required";
|
|
132
|
+
if (!/^[a-z0-9-_]+$/i.test(input)) {
|
|
133
|
+
return "Project name can only contain letters, numbers, hyphens, and underscores";
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
]);
|
|
139
|
+
projectName = answers.projectName;
|
|
140
|
+
}
|
|
141
|
+
await createProject(projectName);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// Standalone runner for create-ikas-component command
|
|
145
|
+
export async function run() {
|
|
146
|
+
const program = new Command();
|
|
147
|
+
program
|
|
148
|
+
.name("create-ikas-component")
|
|
149
|
+
.description("Create a new ikas component project")
|
|
150
|
+
.argument("[name]", "Project name")
|
|
151
|
+
.action(async (name) => {
|
|
152
|
+
let projectName = name;
|
|
153
|
+
if (!projectName) {
|
|
154
|
+
const answers = await inquirer.prompt([
|
|
155
|
+
{
|
|
156
|
+
type: "input",
|
|
157
|
+
name: "projectName",
|
|
158
|
+
message: "What is your project name?",
|
|
159
|
+
default: "my-ikas-components",
|
|
160
|
+
validate: (input) => {
|
|
161
|
+
if (!input.trim())
|
|
162
|
+
return "Project name is required";
|
|
163
|
+
if (!/^[a-z0-9-_]+$/i.test(input)) {
|
|
164
|
+
return "Project name can only contain letters, numbers, hyphens, and underscores";
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]);
|
|
170
|
+
projectName = answers.projectName;
|
|
171
|
+
}
|
|
172
|
+
await createProject(projectName);
|
|
173
|
+
});
|
|
174
|
+
program.parse(process.argv);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMpD,MAAM,UAAU,GAAG;IACjB,MA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C,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;4BAClC,OAAO,0EAA0E,CAAC;wBACpF,CAAC;wBACD,OAAO,IAAI,CAAC;oBACd,CAAC;iBACF;aACF,CAAC,CAAC;YACH,WAAW,GAAG,OAAO,CAAC,WAAqB,CAAC;QAC9C,CAAC;QAED,MAAM,aAAa,CAAC,WAAY,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-page-sections.d.ts","sourceRoot":"","sources":["../../src/commands/list-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list-page-sections.d.ts","sourceRoot":"","sources":["../../src/commands/list-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC,wBAAgB,6BAA6B,IAAI,OAAO,CAYvD"}
|
|
@@ -6,7 +6,11 @@ async function runListPageSections(options) {
|
|
|
6
6
|
}
|
|
7
7
|
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
8
8
|
try {
|
|
9
|
-
const result = await runEditorAction("list-page-sections", {
|
|
9
|
+
const result = await runEditorAction("list-page-sections", {
|
|
10
|
+
pageId: options.pageId,
|
|
11
|
+
...(options.sfRoutingId ? { sfRoutingId: options.sfRoutingId } : {}),
|
|
12
|
+
...(options.specificationId ? { specificationId: options.specificationId } : {}),
|
|
13
|
+
}, port ? { port } : {});
|
|
10
14
|
printResultAndExit(result);
|
|
11
15
|
}
|
|
12
16
|
catch (e) {
|
|
@@ -16,8 +20,10 @@ async function runListPageSections(options) {
|
|
|
16
20
|
export function createListPageSectionsCommand() {
|
|
17
21
|
const cmd = new Command("list-page-sections");
|
|
18
22
|
cmd
|
|
19
|
-
.description("List the sections placed on a page, each with its per-placement elementId, sectionId, current prop values, and blueprint props. Use the elementId with `ikas-component update-section-prop`. COMMON (global) sections — the theme's header/footer — carry a `common` block: their prop values are not page-specific but shared theme-wide and stored on the INDEX (Home) page's placement.")
|
|
23
|
+
.description("List the sections placed on a page, each with its per-placement elementId, sectionId, current prop values, and blueprint props. Use the elementId with `ikas-component update-section-prop`. COMMON (global) sections — the theme's header/footer — carry a `common` block: their prop values are not page-specific but shared theme-wide and stored on the INDEX (Home) page's placement. A page customized per storefront-routing/specification holds a SEPARATE set of placements and its own section order in each state: by default this lists the BASE layer and reports the available states in `pageStates`; pass --sf-routing-id (and --specification-id) to list one of them instead.")
|
|
20
24
|
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
25
|
+
.option("--sf-routing-id <id>", "List a routing-customized state of the page instead of the base layer")
|
|
26
|
+
.option("--specification-id <id>", "Specification of the customized state (used with --sf-routing-id)")
|
|
21
27
|
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
22
28
|
.action(runListPageSections);
|
|
23
29
|
return cmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-page-sections.js","sourceRoot":"","sources":["../../src/commands/list-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"list-page-sections.js","sourceRoot":"","sources":["../../src/commands/list-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAS1C,KAAK,UAAU,mBAAmB,CAAC,OAAgC;IACjE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,Q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AC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-page-section.d.ts","sourceRoot":"","sources":["../../src/commands/move-page-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"move-page-section.d.ts","sourceRoot":"","sources":["../../src/commands/move-page-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+DpC,wBAAgB,4BAA4B,IAAI,OAAO,CAsBtD"}
|
|
@@ -29,6 +29,8 @@ async function runMovePageSection(options) {
|
|
|
29
29
|
pageId: options.pageId,
|
|
30
30
|
elementId: options.elementId,
|
|
31
31
|
...(options.direction ? { direction: options.direction } : { toIndex }),
|
|
32
|
+
...(options.sfRoutingId ? { sfRoutingId: options.sfRoutingId } : {}),
|
|
33
|
+
...(options.specificationId ? { specificationId: options.specificationId } : {}),
|
|
32
34
|
}, port ? { port } : {});
|
|
33
35
|
printResultAndExit(result);
|
|
34
36
|
}
|
|
@@ -45,12 +47,14 @@ export function createMovePageSectionCommand() {
|
|
|
45
47
|
"Indices are 0-based and count only placed sections — the same order `list-page-sections` returns.",
|
|
46
48
|
"The result echoes the resulting order (`sections`) plus `resultIndex`, so you can assert on where the section actually landed rather than assuming. A reorder that does not take effect is returned as an ERROR, never as a success that changed nothing.",
|
|
47
49
|
"COMMON (global) sections — the theme's header/footer — cannot be reordered; their position is fixed by the theme and the call is rejected.",
|
|
48
|
-
"SCOPE: reorders the page's BASE layer. A page customized per storefront-routing/specification holds a SEPARATE section order in each of those states;
|
|
50
|
+
"SCOPE: by default reorders the page's BASE layer. A page customized per storefront-routing/specification holds a SEPARATE section order in each of those states. Pass --sf-routing-id (and --specification-id) to reorder one of those states instead; without them the states are untouched. When the page has any state, the result carries `scope`, `pageStates` and `pageStatesNote` — check them before treating the reorder as complete. List a state's own placements with `ikas-component list-page-sections --sf-routing-id ...`. The state must already exist (creating one duplicates the page and is a deliberate editor action, so it is never done automatically).",
|
|
49
51
|
].join("\n"))
|
|
50
52
|
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
51
53
|
.requiredOption("--element-id <id>", "Placed section elementId (from `ikas-component list-page-sections`)")
|
|
52
54
|
.option("--to-index <n>", "Absolute 0-based target position among the page's sections")
|
|
53
55
|
.option("--direction <up|down>", "Move one position up or down (alternative to --to-index)")
|
|
56
|
+
.option("--sf-routing-id <id>", "Reorder a routing-customized state of the page instead of the base layer")
|
|
57
|
+
.option("--specification-id <id>", "Specification of the customized state (used with --sf-routing-id)")
|
|
54
58
|
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
55
59
|
.action(runMovePageSection);
|
|
56
60
|
return cmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-page-section.js","sourceRoot":"","sources":["../../src/commands/move-page-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"move-page-section.js","sourceRoot":"","sources":["../../src/commands/move-page-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAY1C,KAAK,UAAU,kBAAkB,CAAC,OAA+B;IAC/D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1D,iBAAiB,CAAC,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC,CAAC;IAC1G,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChE,iBAAiB,CACf,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C;IAC9B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-theme-global-name-lookup.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/detect-theme-global-name-lookup.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { detectThemeGlobalNameLookup } from "../detect-theme-global-name-lookup.js";
|
|
2
|
+
const scan = (src) => detectThemeGlobalNameLookup(src, "src/test.tsx");
|
|
3
|
+
describe("detectThemeGlobalNameLookup", () => {
|
|
4
|
+
// ---- Positives: by-name lookups that must be flagged ----
|
|
5
|
+
it("flags a chained .find by name", () => {
|
|
6
|
+
const findings = scan(`
|
|
7
|
+
import { getThemeColors } from "@ikas/bp-storefront";
|
|
8
|
+
const primary = getThemeColors().find(c => c.name === "Primary");
|
|
9
|
+
`);
|
|
10
|
+
expect(findings).toHaveLength(1);
|
|
11
|
+
expect(findings[0].accessor).toBe("getThemeColors");
|
|
12
|
+
expect(findings[0].line).toBe(3);
|
|
13
|
+
});
|
|
14
|
+
it("flags a var-stored result filtered by name", () => {
|
|
15
|
+
const findings = scan(`
|
|
16
|
+
import { getThemeKeyframes } from "@ikas/bp-storefront";
|
|
17
|
+
const kfs = getThemeKeyframes();
|
|
18
|
+
const hover = kfs.find(k => k.name === "hoverLift");
|
|
19
|
+
`);
|
|
20
|
+
expect(findings).toHaveLength(1);
|
|
21
|
+
expect(findings[0].accessor).toBe("getThemeKeyframes");
|
|
22
|
+
});
|
|
23
|
+
it("flags a .filter by displayName", () => {
|
|
24
|
+
const findings = scan(`
|
|
25
|
+
import { getThemeSettings } from "@ikas/bp-storefront";
|
|
26
|
+
const matches = getThemeSettings().filter(s => s.displayName === "Brand Color");
|
|
27
|
+
`);
|
|
28
|
+
expect(findings).toHaveLength(1);
|
|
29
|
+
expect(findings[0].accessor).toBe("getThemeSettings");
|
|
30
|
+
});
|
|
31
|
+
it("flags a destructured callback param compared by name", () => {
|
|
32
|
+
const findings = scan(`
|
|
33
|
+
import { getThemeTypography } from "@ikas/bp-storefront";
|
|
34
|
+
const heading = getThemeTypography().find(({ name }) => name === "Heading");
|
|
35
|
+
`);
|
|
36
|
+
expect(findings).toHaveLength(1);
|
|
37
|
+
expect(findings[0].accessor).toBe("getThemeTypography");
|
|
38
|
+
});
|
|
39
|
+
it("flags name lookup on getThemeColorSchemes().values", () => {
|
|
40
|
+
const findings = scan(`
|
|
41
|
+
import { getThemeColorSchemes } from "@ikas/bp-storefront";
|
|
42
|
+
const dark = getThemeColorSchemes().values.find(v => v.name === "Dark");
|
|
43
|
+
`);
|
|
44
|
+
expect(findings).toHaveLength(1);
|
|
45
|
+
expect(findings[0].accessor).toBe("getThemeColorSchemes");
|
|
46
|
+
});
|
|
47
|
+
// ---- Negatives: id-based / unrelated usage that must NOT be flagged ----
|
|
48
|
+
it("does not flag id/ref-based lookup", () => {
|
|
49
|
+
const findings = scan(`
|
|
50
|
+
import { getThemeKeyframes } from "@ikas/bp-storefront";
|
|
51
|
+
const hover = getThemeKeyframes().find(k => k.ref === "_i3x5JPYbPI");
|
|
52
|
+
`);
|
|
53
|
+
expect(findings).toHaveLength(0);
|
|
54
|
+
});
|
|
55
|
+
it("does not flag mapping to a stable field", () => {
|
|
56
|
+
const findings = scan(`
|
|
57
|
+
import { getThemeColors } from "@ikas/bp-storefront";
|
|
58
|
+
const vars = getThemeColors().map(c => c.cssVar);
|
|
59
|
+
`);
|
|
60
|
+
expect(findings).toHaveLength(0);
|
|
61
|
+
});
|
|
62
|
+
it("does not flag a .name compare on a non-accessor array", () => {
|
|
63
|
+
const findings = scan(`
|
|
64
|
+
const products = getProducts();
|
|
65
|
+
const found = products.find(p => p.name === "Shirt");
|
|
66
|
+
`);
|
|
67
|
+
expect(findings).toHaveLength(0);
|
|
68
|
+
});
|
|
69
|
+
it("does not flag getThemeSetting by stable key", () => {
|
|
70
|
+
const findings = scan(`
|
|
71
|
+
import { getThemeSetting } from "@ikas/bp-storefront";
|
|
72
|
+
const v = getThemeSetting("_6Q0KV7VGGM");
|
|
73
|
+
`);
|
|
74
|
+
expect(findings).toHaveLength(0);
|
|
75
|
+
});
|
|
76
|
+
it("returns empty for source without any theme accessor", () => {
|
|
77
|
+
expect(scan(`const x = [1, 2, 3].find(n => n === 2);`)).toHaveLength(0);
|
|
78
|
+
});
|
|
79
|
+
it("is resilient to unparsable source", () => {
|
|
80
|
+
expect(scan(`getThemeColors().find(c => c.name === `)).toEqual(expect.any(Array));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=detect-theme-global-name-lookup.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-theme-global-name-lookup.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/detect-theme-global-name-lookup.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAEpF,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,2BAA2B,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;AAE/E,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,4DAA4D;IAE5D,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC;;;KAGrB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC;;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,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC;;;KAGrB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC;;;KAGrB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC;;;KAGrB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect when a code component (or a shared module it imports) resolves a theme
|
|
3
|
+
* global by its human NAME instead of its stable id — e.g.
|
|
4
|
+
*
|
|
5
|
+
* getThemeColors().find(c => c.name === "Primary")
|
|
6
|
+
* const cols = getThemeColors(); cols.find(c => c.name === "Primary")
|
|
7
|
+
*
|
|
8
|
+
* Why this matters: a customer can install TWO partner design assets into ONE
|
|
9
|
+
* theme. Each asset brings its own globals, so two colors named "Primary" (with
|
|
10
|
+
* DIFFERENT stable ids) can coexist. Every SDK accessor resolves by stable id
|
|
11
|
+
* (`getThemeSetting("_id")`, `var(--id)`, `_id` class/ref), so id-based code is
|
|
12
|
+
* collision-safe. The ONLY way to pick the wrong "Primary" is to filter an
|
|
13
|
+
* accessor RESULT by `.name` / `.displayName` — names are not unique, and
|
|
14
|
+
* `.find` returns whichever happens to come first. This detector flags exactly
|
|
15
|
+
* that anti-pattern so publish can warn the author to reference by id.
|
|
16
|
+
*
|
|
17
|
+
* AST (not a regex on minified output): the CLI already depends on `typescript`,
|
|
18
|
+
* and at build time the partner SOURCE is available, where the accessor call and
|
|
19
|
+
* the callback param are intact. A minified-bundle scan would be both noisy
|
|
20
|
+
* (every `product.name ===`) and leaky (a result stored in a var breaks the
|
|
21
|
+
* chain). This runs on source, so it sees both the chained and var-stored forms.
|
|
22
|
+
*/
|
|
23
|
+
export type ThemeGlobalNameLookupFinding = {
|
|
24
|
+
/** Source path relative to the project root. */
|
|
25
|
+
file: string;
|
|
26
|
+
/** 1-based line of the offending array-method call. */
|
|
27
|
+
line: number;
|
|
28
|
+
/** The theme accessor whose result is filtered by name (e.g. "getThemeColors"). */
|
|
29
|
+
accessor: string;
|
|
30
|
+
/** Short single-line excerpt of the offending expression. */
|
|
31
|
+
snippet: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Scan one source file's text and return findings for any by-name theme-global
|
|
35
|
+
* lookup. Resilient: a parse failure yields no findings (the lint never blocks a build).
|
|
36
|
+
*/
|
|
37
|
+
export declare function detectThemeGlobalNameLookup(sourceText: string, fileName: string): ThemeGlobalNameLookupFinding[];
|
|
38
|
+
//# sourceMappingURL=detect-theme-global-name-lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-theme-global-name-lookup.d.ts","sourceRoot":"","sources":["../../src/utils/detect-theme-global-name-lookup.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,4BAA4B,GAAG;IACzC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAwIF;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,4BAA4B,EAAE,CA2ChC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
// SDK accessors that return a LIST of tokens, each carrying a non-unique `name`.
|
|
3
|
+
// `getThemeSetting`/`getThemeSettingValue` are intentionally excluded: they take a
|
|
4
|
+
// stable key argument, not a name, so they cannot be name-filtered. Duplicated here
|
|
5
|
+
// (not imported from editor-core) because the CLI ships standalone to npm — same
|
|
6
|
+
// convention as the duplicated CSS scoper in compile.ts.
|
|
7
|
+
const LIST_ACCESSORS = new Set([
|
|
8
|
+
"getThemeColors",
|
|
9
|
+
"getThemeKeyframes",
|
|
10
|
+
"getThemeTypography",
|
|
11
|
+
"getThemeBreakpoints",
|
|
12
|
+
"getThemeSettings",
|
|
13
|
+
"getThemeColorSchemes",
|
|
14
|
+
]);
|
|
15
|
+
// Array methods that take a per-element predicate/callback where a `.name` compare
|
|
16
|
+
// would live. `map`/`forEach`/`reduce` are included because a name compare can hide
|
|
17
|
+
// in any of them (e.g. `getThemeColors().map(c => c.name === target ? ... : ...)`).
|
|
18
|
+
const ARRAY_CALLBACK_METHODS = new Set([
|
|
19
|
+
"find",
|
|
20
|
+
"filter",
|
|
21
|
+
"some",
|
|
22
|
+
"every",
|
|
23
|
+
"findIndex",
|
|
24
|
+
"findLast",
|
|
25
|
+
"findLastIndex",
|
|
26
|
+
"forEach",
|
|
27
|
+
"map",
|
|
28
|
+
"flatMap",
|
|
29
|
+
"reduce",
|
|
30
|
+
]);
|
|
31
|
+
// Token properties whose comparison signals a by-name lookup. `name` and the
|
|
32
|
+
// settings token's `displayName` are the human labels; everything stable
|
|
33
|
+
// (`id`/`ref`/`cssVar`/`className`) is fine and intentionally NOT listed.
|
|
34
|
+
const NAME_PROPS = new Set(["name", "displayName"]);
|
|
35
|
+
/** The accessor name if `node` is (or unwraps to) a call to a LIST_ACCESSOR, else undefined. */
|
|
36
|
+
function listAccessorOf(node) {
|
|
37
|
+
// Unwrap `getThemeColorSchemes().values` / `.schemes` and parenthesized forms so the
|
|
38
|
+
// underlying accessor call is still recognized.
|
|
39
|
+
let expr = node;
|
|
40
|
+
if (ts.isParenthesizedExpression(expr))
|
|
41
|
+
expr = expr.expression;
|
|
42
|
+
if (ts.isPropertyAccessExpression(expr))
|
|
43
|
+
expr = expr.expression;
|
|
44
|
+
if (ts.isParenthesizedExpression(expr))
|
|
45
|
+
expr = expr.expression;
|
|
46
|
+
if (!ts.isCallExpression(expr))
|
|
47
|
+
return undefined;
|
|
48
|
+
const callee = expr.expression;
|
|
49
|
+
const name = ts.isIdentifier(callee)
|
|
50
|
+
? callee.text
|
|
51
|
+
: ts.isPropertyAccessExpression(callee)
|
|
52
|
+
? callee.name.text
|
|
53
|
+
: undefined;
|
|
54
|
+
return name && LIST_ACCESSORS.has(name) ? name : undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Collect local `const x = getTheme*()` bindings so var-stored results are also tracked. */
|
|
57
|
+
function collectAccessorBoundVars(sourceFile) {
|
|
58
|
+
const bound = new Map();
|
|
59
|
+
const visit = (node) => {
|
|
60
|
+
if (ts.isVariableDeclaration(node) &&
|
|
61
|
+
node.initializer &&
|
|
62
|
+
ts.isIdentifier(node.name)) {
|
|
63
|
+
const accessor = listAccessorOf(node.initializer);
|
|
64
|
+
if (accessor)
|
|
65
|
+
bound.set(node.name.text, accessor);
|
|
66
|
+
}
|
|
67
|
+
ts.forEachChild(node, visit);
|
|
68
|
+
};
|
|
69
|
+
visit(sourceFile);
|
|
70
|
+
return bound;
|
|
71
|
+
}
|
|
72
|
+
/** True if the callback compares its iterated element's `.name`/`.displayName`. */
|
|
73
|
+
function callbackComparesName(callback, sourceFile) {
|
|
74
|
+
if (!ts.isArrowFunction(callback) && !ts.isFunctionExpression(callback))
|
|
75
|
+
return false;
|
|
76
|
+
const firstParam = callback.parameters[0];
|
|
77
|
+
if (!firstParam)
|
|
78
|
+
return false;
|
|
79
|
+
// Element accessed as `param.name` — the common `c => c.name === ...` form.
|
|
80
|
+
const paramName = ts.isIdentifier(firstParam.name) ? firstParam.name.text : undefined;
|
|
81
|
+
// Element destructured as `({ name }) => name === ...`.
|
|
82
|
+
const destructuredNames = new Set();
|
|
83
|
+
if (ts.isObjectBindingPattern(firstParam.name)) {
|
|
84
|
+
for (const el of firstParam.name.elements) {
|
|
85
|
+
const prop = el.propertyName ?? el.name;
|
|
86
|
+
if (ts.isIdentifier(prop) && NAME_PROPS.has(prop.text)) {
|
|
87
|
+
if (ts.isIdentifier(el.name))
|
|
88
|
+
destructuredNames.add(el.name.text);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!paramName && destructuredNames.size === 0)
|
|
93
|
+
return false;
|
|
94
|
+
let found = false;
|
|
95
|
+
const visit = (node) => {
|
|
96
|
+
if (found)
|
|
97
|
+
return;
|
|
98
|
+
// `param.name` / `param.displayName` referenced anywhere in the body.
|
|
99
|
+
if (paramName &&
|
|
100
|
+
ts.isPropertyAccessExpression(node) &&
|
|
101
|
+
ts.isIdentifier(node.expression) &&
|
|
102
|
+
node.expression.text === paramName &&
|
|
103
|
+
NAME_PROPS.has(node.name.text)) {
|
|
104
|
+
found = true;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// A destructured `name`/`displayName` identifier used in an equality compare.
|
|
108
|
+
if (destructuredNames.size > 0 && ts.isBinaryExpression(node)) {
|
|
109
|
+
const op = node.operatorToken.kind;
|
|
110
|
+
const isEq = op === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
111
|
+
op === ts.SyntaxKind.EqualsEqualsToken ||
|
|
112
|
+
op === ts.SyntaxKind.ExclamationEqualsEqualsToken ||
|
|
113
|
+
op === ts.SyntaxKind.ExclamationEqualsToken;
|
|
114
|
+
if (isEq) {
|
|
115
|
+
for (const side of [node.left, node.right]) {
|
|
116
|
+
if (ts.isIdentifier(side) && destructuredNames.has(side.text)) {
|
|
117
|
+
found = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
ts.forEachChild(node, visit);
|
|
124
|
+
};
|
|
125
|
+
visit(callback);
|
|
126
|
+
return found;
|
|
127
|
+
}
|
|
128
|
+
function oneLineSnippet(node, sourceFile) {
|
|
129
|
+
const text = node.getText(sourceFile).replace(/\s+/g, " ").trim();
|
|
130
|
+
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Scan one source file's text and return findings for any by-name theme-global
|
|
134
|
+
* lookup. Resilient: a parse failure yields no findings (the lint never blocks a build).
|
|
135
|
+
*/
|
|
136
|
+
export function detectThemeGlobalNameLookup(sourceText, fileName) {
|
|
137
|
+
if (!sourceText.includes("getTheme"))
|
|
138
|
+
return [];
|
|
139
|
+
const findings = [];
|
|
140
|
+
try {
|
|
141
|
+
const sourceFile = ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.Latest,
|
|
142
|
+
/* setParentNodes */ true, fileName.endsWith(".tsx") || fileName.endsWith(".jsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
143
|
+
const boundVars = collectAccessorBoundVars(sourceFile);
|
|
144
|
+
const visit = (node) => {
|
|
145
|
+
// Looking for `<arraySource>.<method>(<callback>)`.
|
|
146
|
+
if (ts.isCallExpression(node) &&
|
|
147
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
148
|
+
ARRAY_CALLBACK_METHODS.has(node.expression.name.text) &&
|
|
149
|
+
node.arguments.length > 0) {
|
|
150
|
+
const arraySource = node.expression.expression;
|
|
151
|
+
// (a) direct chain on an accessor call, or (b) a var bound to an accessor result.
|
|
152
|
+
const accessor = listAccessorOf(arraySource) ??
|
|
153
|
+
(ts.isIdentifier(arraySource) ? boundVars.get(arraySource.text) : undefined);
|
|
154
|
+
if (accessor && callbackComparesName(node.arguments[0], sourceFile)) {
|
|
155
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
156
|
+
findings.push({
|
|
157
|
+
file: fileName,
|
|
158
|
+
line: line + 1,
|
|
159
|
+
accessor,
|
|
160
|
+
snippet: oneLineSnippet(node, sourceFile),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
ts.forEachChild(node, visit);
|
|
165
|
+
};
|
|
166
|
+
visit(sourceFile);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
return findings;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=detect-theme-global-name-lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-theme-global-name-lookup.js","sourceRoot":"","sources":["../../src/utils/detect-theme-global-name-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAoCjC,iFAAiF;AACjF,mFAAmF;AACnF,oFAAoF;AACpF,iFAAiF;AACjF,yDAAyD;AACzD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,sBAAsB;CACvB,CAAC,CAAC;AAEH,mFAAmF;AACnF,oF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C,IAAI,EAAE,UAAU,CAAC;qBAC1C,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/component-cli",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.155",
|
|
4
4
|
"description": "CLI for developing ikas code components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./build-tools":
|
|
13
|
+
"./build-tools": {
|
|
14
|
+
"types": "./dist/build-tools.d.ts",
|
|
15
|
+
"default": "./dist/build-tools.js"
|
|
16
|
+
},
|
|
14
17
|
"./package.json": "./package.json"
|
|
15
18
|
},
|
|
16
19
|
"bin": {
|