@ikas/component-cli 1.4.0-beta.160 → 1.4.0-beta.161
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 +19 -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 +228 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/get-available-values.d.ts +3 -0
- package/dist/commands/get-available-values.d.ts.map +1 -0
- package/dist/commands/get-available-values.js +49 -0
- package/dist/commands/get-available-values.js.map +1 -0
- package/dist/commands/proxy.d.ts +39 -0
- package/dist/commands/proxy.d.ts.map +1 -0
- package/dist/commands/proxy.js +210 -0
- package/dist/commands/proxy.js.map +1 -0
- package/dist/commands/search-categories.d.ts +3 -0
- package/dist/commands/search-categories.d.ts.map +1 -0
- package/dist/commands/search-categories.js +26 -0
- package/dist/commands/search-categories.js.map +1 -0
- package/dist/commands/set-dynamic-value.d.ts +3 -0
- package/dist/commands/set-dynamic-value.d.ts.map +1 -0
- package/dist/commands/set-dynamic-value.js +54 -0
- package/dist/commands/set-dynamic-value.js.map +1 -0
- package/dist/commands/update-section-props.d.ts +3 -0
- package/dist/commands/update-section-props.d.ts.map +1 -0
- package/dist/commands/update-section-props.js +43 -0
- package/dist/commands/update-section-props.js.map +1 -0
- package/dist/utils/compile.d.ts +13 -1
- package/dist/utils/compile.d.ts.map +1 -1
- package/dist/utils/compile.js +53 -12
- package/dist/utils/compile.js.map +1 -1
- package/dist/utils/esm-transform.d.ts.map +1 -1
- package/dist/utils/esm-transform.js +18 -2
- package/dist/utils/esm-transform.js.map +1 -1
- package/dist/utils/forbid-external-packages.d.ts +11 -1
- package/dist/utils/forbid-external-packages.d.ts.map +1 -1
- package/dist/utils/forbid-external-packages.js +3 -1
- package/dist/utils/forbid-external-packages.js.map +1 -1
- package/dist/utils/theme-source-archive.d.ts +25 -0
- package/dist/utils/theme-source-archive.d.ts.map +1 -0
- package/dist/utils/theme-source-archive.js +70 -0
- package/dist/utils/theme-source-archive.js.map +1 -0
- package/dist/utils/upload-theme-source.d.ts +32 -0
- package/dist/utils/upload-theme-source.d.ts.map +1 -0
- package/dist/utils/upload-theme-source.js +21 -0
- package/dist/utils/upload-theme-source.js.map +1 -0
- package/dist/utils/vendor-storefront.d.ts +13 -0
- package/dist/utils/vendor-storefront.d.ts.map +1 -0
- package/dist/utils/vendor-storefront.js +91 -0
- package/dist/utils/vendor-storefront.js.map +1 -0
- package/package.json +5 -2
package/dist/build-tools.d.ts
CHANGED
|
@@ -5,7 +5,26 @@
|
|
|
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";
|
|
15
|
+
export type { CompileAllOptions } from "./utils/compile.js";
|
|
10
16
|
export { buildChunkMapping, transformChunkForCanvas, transformEsmToWindowGlobals } from "./utils/esm-transform.js";
|
|
17
|
+
/**
|
|
18
|
+
* What a prop type means in TypeScript — the table `generateTypesFile` writes a component's
|
|
19
|
+
* types.ts from. Exported because @ikas/builtin-components generates the same file for the
|
|
20
|
+
* built-in components and has to produce byte-identical output; before this it kept a copy,
|
|
21
|
+
* and a copy of this table is a silently wrong prop type in every component it describes.
|
|
22
|
+
*
|
|
23
|
+
* Note that `@ikas/editor-models` exports a third variant of the same mapping
|
|
24
|
+
* (`PropTypeToTSType`) which does NOT agree with this one — it maps COMPONENT to
|
|
25
|
+
* `ComponentChild` rather than `any` and carries RAFFLE/FUNCTION entries this table lacks.
|
|
26
|
+
* This one is authoritative for anything emitting a component's types.ts, because it is the
|
|
27
|
+
* one the CLI itself writes with.
|
|
28
|
+
*/
|
|
29
|
+
export { PROP_TYPE_TO_TS } from "./utils/component-helpers.js";
|
|
11
30
|
//# 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,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,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;AAE1D,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;AAsKpC,wBAAgB,mBAAmB,IAAI,OAAO,CA+C7C;AAGD,wBAAsB,GAAG,kBAoDxB"}
|
|
@@ -0,0 +1,228 @@
|
|
|
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, generateUniqueId } from "../utils/component-helpers.js";
|
|
8
|
+
import { readTemplate, readTemplateDirectory } from "../utils/template.js";
|
|
9
|
+
async function createProject(projectName, template = "blank") {
|
|
10
|
+
const spinner = ora("Creating project...").start();
|
|
11
|
+
try {
|
|
12
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
13
|
+
// Check if directory exists
|
|
14
|
+
if (fs.existsSync(projectPath)) {
|
|
15
|
+
spinner.fail(`Directory "${projectName}" already exists`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
// Generate project ID
|
|
19
|
+
const projectId = generateProjectId();
|
|
20
|
+
const vars = {
|
|
21
|
+
PROJECT_NAME: projectName,
|
|
22
|
+
PROJECT_ID: projectId,
|
|
23
|
+
EXAMPLE_COMPONENT_ID: generateComponentId(projectId, "example-component"),
|
|
24
|
+
EXAMPLE_SECTION_ID: generateComponentId(projectId, "example-section"),
|
|
25
|
+
};
|
|
26
|
+
if (template === "full") {
|
|
27
|
+
// Generate unique IDs for custom enum types and privateVarMap entries
|
|
28
|
+
vars.ENUM_COLUMNS_ID = generateUniqueId();
|
|
29
|
+
vars.ENUM_ASPECT_RATIO_ID = generateUniqueId();
|
|
30
|
+
vars.ENUM_OBJECT_FIT_ID = generateUniqueId();
|
|
31
|
+
vars.ENUM_VERTICAL_ALIGN_ID = generateUniqueId();
|
|
32
|
+
vars.PVM_ID_1 = `pvm_${Date.now()}_1`;
|
|
33
|
+
vars.PVM_ID_2 = `pvm_${Date.now()}_2`;
|
|
34
|
+
vars.PVM_ID_3 = `pvm_${Date.now()}_3`;
|
|
35
|
+
vars.PVM_ID_4 = `pvm_${Date.now()}_4`;
|
|
36
|
+
await createFullProject(projectPath, vars, spinner);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await createBlankProject(projectPath, vars, spinner);
|
|
40
|
+
}
|
|
41
|
+
// Create or merge .cursor/mcp.json for Cursor editor
|
|
42
|
+
const cursorDir = path.join(projectPath, ".cursor");
|
|
43
|
+
const cursorMcpPath = path.join(cursorDir, "mcp.json");
|
|
44
|
+
fs.mkdirSync(cursorDir, { recursive: true });
|
|
45
|
+
let cursorMcpConfig = { mcpServers: {} };
|
|
46
|
+
if (fs.existsSync(cursorMcpPath)) {
|
|
47
|
+
try {
|
|
48
|
+
cursorMcpConfig = JSON.parse(fs.readFileSync(cursorMcpPath, "utf-8"));
|
|
49
|
+
if (!cursorMcpConfig.mcpServers) {
|
|
50
|
+
cursorMcpConfig.mcpServers = {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
cursorMcpConfig = { mcpServers: {} };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
cursorMcpConfig.mcpServers["ikas-code-components"] = {
|
|
58
|
+
command: "node",
|
|
59
|
+
args: ["${workspaceFolder}/node_modules/@ikas/code-components-mcp/dist/index.js"]
|
|
60
|
+
};
|
|
61
|
+
fs.writeFileSync(cursorMcpPath, JSON.stringify(cursorMcpConfig, null, 2));
|
|
62
|
+
spinner.succeed(chalk.green(`Project "${projectName}" created successfully! (template: ${template})`));
|
|
63
|
+
console.log("\n" + chalk.cyan("Next steps:"));
|
|
64
|
+
console.log(chalk.white(` cd ${projectName}`));
|
|
65
|
+
console.log(chalk.white(" npm install"));
|
|
66
|
+
console.log(chalk.white(" npm run dev"));
|
|
67
|
+
if (template === "full") {
|
|
68
|
+
console.log("\n" + chalk.yellow("This is a complete theme with 20 sections and 30+ components."));
|
|
69
|
+
console.log(chalk.yellow("See README.md for the full project structure."));
|
|
70
|
+
}
|
|
71
|
+
console.log("\n" + chalk.gray("Happy coding! 🚀"));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
spinner.fail("Failed to create project");
|
|
75
|
+
console.error(error);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function createBlankProject(projectPath, vars, spinner) {
|
|
80
|
+
// Create directory structure
|
|
81
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
|
82
|
+
fs.mkdirSync(path.join(projectPath, "src/components/ExampleComponent"), { recursive: true });
|
|
83
|
+
fs.mkdirSync(path.join(projectPath, "src/components/ExampleSection"), { recursive: true });
|
|
84
|
+
// Write all template files
|
|
85
|
+
const files = [
|
|
86
|
+
{ template: "create/package.json", dest: "package.json", vars },
|
|
87
|
+
{ template: "create/tsconfig.json", dest: "tsconfig.json" },
|
|
88
|
+
{ template: "create/vite.config.ts", dest: "vite.config.ts" },
|
|
89
|
+
{ template: "create/ikas.config.json", dest: "ikas.config.json", vars },
|
|
90
|
+
{ template: "create/gitignore", dest: ".gitignore" },
|
|
91
|
+
{ template: "create/mcp.json", dest: ".mcp.json" },
|
|
92
|
+
{ template: "create/README.md", dest: "README.md", vars },
|
|
93
|
+
{ template: "create/claude-md", dest: "CLAUDE.md" },
|
|
94
|
+
{ template: "create/cursorrules", dest: ".cursorrules" },
|
|
95
|
+
{ template: "create/src/global.css", dest: "src/global.css" },
|
|
96
|
+
{ template: "create/src/global-types.ts", dest: "src/global-types.ts" },
|
|
97
|
+
{ template: "create/src/ikas-component-utils.d.ts", dest: "src/ikas-component-utils.d.ts" },
|
|
98
|
+
{ template: "create/src/components/index.ts", dest: "src/components/index.ts" },
|
|
99
|
+
{ template: "create/src/components/ExampleComponent/index.tsx", dest: "src/components/ExampleComponent/index.tsx" },
|
|
100
|
+
{ template: "create/src/components/ExampleComponent/types.ts", dest: "src/components/ExampleComponent/types.ts" },
|
|
101
|
+
{ template: "create/src/components/ExampleComponent/styles.css", dest: "src/components/ExampleComponent/styles.css" },
|
|
102
|
+
{ template: "create/src/components/ExampleSection/index.tsx", dest: "src/components/ExampleSection/index.tsx" },
|
|
103
|
+
{ template: "create/src/components/ExampleSection/types.ts", dest: "src/components/ExampleSection/types.ts" },
|
|
104
|
+
{ template: "create/src/components/ExampleSection/styles.css", dest: "src/components/ExampleSection/styles.css" },
|
|
105
|
+
];
|
|
106
|
+
for (const file of files) {
|
|
107
|
+
fs.writeFileSync(path.join(projectPath, file.dest), readTemplate(file.template, file.vars));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function createFullProject(projectPath, vars, spinner) {
|
|
111
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
|
112
|
+
spinner.text = "Creating full theme project (350+ files)...";
|
|
113
|
+
const templateFiles = readTemplateDirectory("create-full", vars);
|
|
114
|
+
for (const file of templateFiles) {
|
|
115
|
+
// Map template filenames to actual filenames
|
|
116
|
+
let destPath = file.relativePath;
|
|
117
|
+
if (destPath === "gitignore")
|
|
118
|
+
destPath = ".gitignore";
|
|
119
|
+
else if (destPath === "claude-md")
|
|
120
|
+
destPath = "CLAUDE.md";
|
|
121
|
+
else if (destPath === "cursorrules")
|
|
122
|
+
destPath = ".cursorrules";
|
|
123
|
+
else if (destPath === "mcp.json")
|
|
124
|
+
destPath = ".mcp.json";
|
|
125
|
+
const fullDest = path.join(projectPath, destPath);
|
|
126
|
+
fs.mkdirSync(path.dirname(fullDest), { recursive: true });
|
|
127
|
+
fs.writeFileSync(fullDest, file.content);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function createCreateCommand() {
|
|
131
|
+
return new Command("create")
|
|
132
|
+
.description("Create a new ikas component project")
|
|
133
|
+
.argument("[name]", "Project name")
|
|
134
|
+
.option("-t, --template <template>", "Template to use: blank or full (complete theme)")
|
|
135
|
+
.action(async (name, opts) => {
|
|
136
|
+
let projectName = name;
|
|
137
|
+
let template;
|
|
138
|
+
if (opts.template) {
|
|
139
|
+
template = opts.template === "full" ? "full" : "blank";
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const answers = await inquirer.prompt([
|
|
143
|
+
{
|
|
144
|
+
type: "list",
|
|
145
|
+
name: "template",
|
|
146
|
+
message: "Which template would you like to use?",
|
|
147
|
+
choices: [
|
|
148
|
+
{ name: "Blank — minimal project with example component and section", value: "blank" },
|
|
149
|
+
{ name: "Full — complete storefront theme with 20 sections and 30+ components", value: "full" },
|
|
150
|
+
],
|
|
151
|
+
}
|
|
152
|
+
]);
|
|
153
|
+
template = answers.template;
|
|
154
|
+
}
|
|
155
|
+
if (!projectName) {
|
|
156
|
+
const answers = await inquirer.prompt([
|
|
157
|
+
{
|
|
158
|
+
type: "input",
|
|
159
|
+
name: "projectName",
|
|
160
|
+
message: "What is your project name?",
|
|
161
|
+
default: "my-ikas-components",
|
|
162
|
+
validate: (input) => {
|
|
163
|
+
if (!input.trim())
|
|
164
|
+
return "Project name is required";
|
|
165
|
+
if (!/^[a-z0-9-_]+$/i.test(input)) {
|
|
166
|
+
return "Project name can only contain letters, numbers, hyphens, and underscores";
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]);
|
|
172
|
+
projectName = answers.projectName;
|
|
173
|
+
}
|
|
174
|
+
await createProject(projectName, template);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// Standalone runner for create-ikas-component command
|
|
178
|
+
export async function run() {
|
|
179
|
+
const program = new Command();
|
|
180
|
+
program
|
|
181
|
+
.name("create-ikas-component")
|
|
182
|
+
.description("Create a new ikas component project")
|
|
183
|
+
.argument("[name]", "Project name")
|
|
184
|
+
.option("-t, --template <template>", "Template to use: blank or full (complete theme)")
|
|
185
|
+
.action(async (name, opts) => {
|
|
186
|
+
let projectName = name;
|
|
187
|
+
let template;
|
|
188
|
+
if (opts.template) {
|
|
189
|
+
template = opts.template === "full" ? "full" : "blank";
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const answers = await inquirer.prompt([
|
|
193
|
+
{
|
|
194
|
+
type: "list",
|
|
195
|
+
name: "template",
|
|
196
|
+
message: "Which template would you like to use?",
|
|
197
|
+
choices: [
|
|
198
|
+
{ name: "Blank — minimal project with example component and section", value: "blank" },
|
|
199
|
+
{ name: "Full — complete storefront theme with 20 sections and 30+ components", value: "full" },
|
|
200
|
+
],
|
|
201
|
+
}
|
|
202
|
+
]);
|
|
203
|
+
template = answers.template;
|
|
204
|
+
}
|
|
205
|
+
if (!projectName) {
|
|
206
|
+
const answers = await inquirer.prompt([
|
|
207
|
+
{
|
|
208
|
+
type: "input",
|
|
209
|
+
name: "projectName",
|
|
210
|
+
message: "What is your project name?",
|
|
211
|
+
default: "my-ikas-components",
|
|
212
|
+
validate: (input) => {
|
|
213
|
+
if (!input.trim())
|
|
214
|
+
return "Project name is required";
|
|
215
|
+
if (!/^[a-z0-9-_]+$/i.test(input)) {
|
|
216
|
+
return "Project name can only contain letters, numbers, hyphens, and underscores";
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
]);
|
|
222
|
+
projectName = answers.projectName;
|
|
223
|
+
}
|
|
224
|
+
await createProject(projectName, template);
|
|
225
|
+
});
|
|
226
|
+
program.parse(process.argv);
|
|
227
|
+
}
|
|
228
|
+
//# 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,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;A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DAA4D,EAAE,KAAK,EAAE,OAAO,EAAE;wBACtF,EAAE,IAAI,EAAE,uEAAuE,EAAE,KAAK,EAAE,MAAM,EAAE;qBACjG;iBACF;aACF,CAAC,CAAC;YACH,QAAQ,GAAG,OAAO,CAAC,QAAwB,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBACpC;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,4BAA4B;oBACrC,OAAO,EAAE,oBAAoB;oBAC7B,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE;wBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;4BAAE,OAAO,0BAA0B,CAAC;wBACrD,IAAI,CAAC,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,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-available-values.d.ts","sourceRoot":"","sources":["../../src/commands/get-available-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoDpC,wBAAgB,+BAA+B,IAAI,OAAO,CAazD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
function parseListPath(raw) {
|
|
4
|
+
if (!raw)
|
|
5
|
+
return undefined;
|
|
6
|
+
let parsed;
|
|
7
|
+
try {
|
|
8
|
+
parsed = JSON.parse(raw);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
printErrorAndExit(new Error('--list-path must be JSON, e.g. \'[{"propId":"<listPropId>","index":0}]\''));
|
|
12
|
+
}
|
|
13
|
+
if (!Array.isArray(parsed)) {
|
|
14
|
+
printErrorAndExit(new Error("--list-path must be a JSON array of { propId, index }."));
|
|
15
|
+
}
|
|
16
|
+
return parsed;
|
|
17
|
+
}
|
|
18
|
+
async function runGetAvailableValues(options) {
|
|
19
|
+
if (!options.elementId) {
|
|
20
|
+
printErrorAndExit(new Error("--element-id is required (from `ikas-component list-page-sections`)"));
|
|
21
|
+
}
|
|
22
|
+
const listPath = parseListPath(options.listPath);
|
|
23
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
24
|
+
try {
|
|
25
|
+
const result = await runEditorAction("get-available-values", {
|
|
26
|
+
...(options.pageId ? { pageId: options.pageId } : {}),
|
|
27
|
+
elementId: options.elementId,
|
|
28
|
+
...(options.propId ? { propId: options.propId } : {}),
|
|
29
|
+
...(listPath ? { listPath } : {}),
|
|
30
|
+
}, port ? { port } : {});
|
|
31
|
+
printResultAndExit(result);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
printErrorAndExit(e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function createGetAvailableValuesCommand() {
|
|
38
|
+
const cmd = new Command("get-available-values");
|
|
39
|
+
cmd
|
|
40
|
+
.description("List the dynamic values that can be BOUND to a prop (store/global/parent/section variables, or the per-item loop variables of a COMPONENT_LIST). Pass --prop-id to filter to that prop's type. For a prop of a component placed inside a COMPONENT_LIST, pass --list-path (JSON, e.g. '[{\"propId\":\"<listPropId>\",\"index\":0}]'). Returns each value's `ref` (pass it as a `ref` in an `update-page-sections` update to bind the prop), displayName, typeId, groupType.")
|
|
41
|
+
.requiredOption("--element-id <id>", "Placed section elementId (from `list-page-sections`)")
|
|
42
|
+
.option("--page-id <id>", "Page id (from `list-pages`)")
|
|
43
|
+
.option("--prop-id <id>", "Target prop id to filter values by its type")
|
|
44
|
+
.option("--list-path <json>", 'JSON path into a COMPONENT_LIST, e.g. \'[{"propId":"<listPropId>","index":0}]\'')
|
|
45
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
46
|
+
.action(runGetAvailableValues);
|
|
47
|
+
return cmd;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=get-available-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-available-values.js","sourceRoot":"","sources":["../../src/commands/get-available-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAU1C,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB,CAAC,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC,CAAC;IAC3G,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,iBAAiB,CAAC,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAkD,CAAC;AAC5D,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,OAAkC;IACrE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,iBAAiB,CAAC,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC,CAAC;IACtG,CAAC;IACD,M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AAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type ViteDevServer } from "vite";
|
|
3
|
+
export declare const DEFAULT_ADMIN_PORT = 3002;
|
|
4
|
+
export declare const DEFAULT_EDITOR_PORT = 3003;
|
|
5
|
+
export declare const PROD_EDITOR_URL = "https://studio.ikasapps.com";
|
|
6
|
+
export declare const PROD_ADMIN_DOMAIN = "myikas.com";
|
|
7
|
+
export declare const DEV_EDITOR_URL = "https://studio-dev.ikasapps.com";
|
|
8
|
+
export declare const DEV_ADMIN_DOMAIN = "myikas.dev";
|
|
9
|
+
export declare const DEFAULT_EDITOR_URL = "https://studio.ikasapps.com";
|
|
10
|
+
export declare const DEFAULT_ADMIN_DOMAIN = "myikas.com";
|
|
11
|
+
export declare const DEFAULT_PROXY_PORT = 3002;
|
|
12
|
+
export interface StartProxyOptions {
|
|
13
|
+
store: string;
|
|
14
|
+
adminPort?: number;
|
|
15
|
+
editorPort?: number;
|
|
16
|
+
editorUrl?: string;
|
|
17
|
+
adminDomain?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ProxyHandle {
|
|
20
|
+
adminVite: ViteDevServer;
|
|
21
|
+
editorVite: ViteDevServer;
|
|
22
|
+
adminTarget: string;
|
|
23
|
+
editorTarget: string;
|
|
24
|
+
adminUrl: string;
|
|
25
|
+
editorUrl: string;
|
|
26
|
+
adminPort: number;
|
|
27
|
+
editorPort: number;
|
|
28
|
+
/** Close both underlying Vite servers. */
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare function startProxy(opts: StartProxyOptions): Promise<ProxyHandle>;
|
|
32
|
+
export declare function printProxyBanner(handle: ProxyHandle): void;
|
|
33
|
+
export declare function promptForStore(): Promise<string>;
|
|
34
|
+
export declare function resolveEnvironmentDefaults(dev: boolean): {
|
|
35
|
+
editorUrl: string;
|
|
36
|
+
adminDomain: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function createProxyCommand(): Command;
|
|
39
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/commands/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAE5E,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAC7D,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C,eAAO,MAAM,cAAc,oCAAoC,CAAC;AAChE,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAG7C,eAAO,MAAM,kBAAkB,gCAAkB,CAAC;AAClD,eAAO,MAAM,oBAAoB,eAAoB,CAAC;AAGtD,eAAO,MAAM,kBAAkB,OAAqB,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CA8E9E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,QAQnD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CActD;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO;;;EAItD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAiC5C"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import { createServer as createViteServer } from "vite";
|
|
5
|
+
export const DEFAULT_ADMIN_PORT = 3002;
|
|
6
|
+
export const DEFAULT_EDITOR_PORT = 3003;
|
|
7
|
+
export const PROD_EDITOR_URL = "https://studio.ikasapps.com";
|
|
8
|
+
export const PROD_ADMIN_DOMAIN = "myikas.com";
|
|
9
|
+
export const DEV_EDITOR_URL = "https://studio-dev.ikasapps.com";
|
|
10
|
+
export const DEV_ADMIN_DOMAIN = "myikas.dev";
|
|
11
|
+
// Default environment = prod. `--dev` flips to dev.
|
|
12
|
+
export const DEFAULT_EDITOR_URL = PROD_EDITOR_URL;
|
|
13
|
+
export const DEFAULT_ADMIN_DOMAIN = PROD_ADMIN_DOMAIN;
|
|
14
|
+
// Kept for the legacy single-port fallback (no longer used by default).
|
|
15
|
+
export const DEFAULT_PROXY_PORT = DEFAULT_ADMIN_PORT;
|
|
16
|
+
export async function startProxy(opts) {
|
|
17
|
+
const adminPort = opts.adminPort ?? DEFAULT_ADMIN_PORT;
|
|
18
|
+
const editorPort = opts.editorPort ?? DEFAULT_EDITOR_PORT;
|
|
19
|
+
const editorTarget = opts.editorUrl ?? DEFAULT_EDITOR_URL;
|
|
20
|
+
const adminDomain = opts.adminDomain ?? DEFAULT_ADMIN_DOMAIN;
|
|
21
|
+
const adminTarget = `https://${opts.store}.${adminDomain}`;
|
|
22
|
+
const adminUrl = `http://localhost:${adminPort}`;
|
|
23
|
+
const editorUrl = `http://localhost:${editorPort}`;
|
|
24
|
+
// Editor proxy: dedicated port so the editor's absolute asset paths
|
|
25
|
+
// (e.g. `/assets/index-*.js`) resolve correctly against its own origin.
|
|
26
|
+
const editorVite = await createViteServer({
|
|
27
|
+
configFile: false,
|
|
28
|
+
appType: "custom",
|
|
29
|
+
logLevel: "warn",
|
|
30
|
+
server: {
|
|
31
|
+
port: editorPort,
|
|
32
|
+
strictPort: true,
|
|
33
|
+
host: "localhost",
|
|
34
|
+
cors: true,
|
|
35
|
+
proxy: {
|
|
36
|
+
"/": {
|
|
37
|
+
target: editorTarget,
|
|
38
|
+
changeOrigin: true,
|
|
39
|
+
secure: true,
|
|
40
|
+
ws: true,
|
|
41
|
+
configure: (proxy) => {
|
|
42
|
+
stripSecurityHeaders(proxy);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
await editorVite.listen();
|
|
49
|
+
// Admin proxy: rewrites the deployed editor origin to our editor proxy URL
|
|
50
|
+
// in any text response so bundled iframe srcs point at localhost.
|
|
51
|
+
const adminVite = await createViteServer({
|
|
52
|
+
configFile: false,
|
|
53
|
+
appType: "custom",
|
|
54
|
+
logLevel: "warn",
|
|
55
|
+
server: {
|
|
56
|
+
port: adminPort,
|
|
57
|
+
strictPort: true,
|
|
58
|
+
host: "localhost",
|
|
59
|
+
cors: true,
|
|
60
|
+
proxy: {
|
|
61
|
+
"/": {
|
|
62
|
+
target: adminTarget,
|
|
63
|
+
changeOrigin: true,
|
|
64
|
+
secure: true,
|
|
65
|
+
ws: true,
|
|
66
|
+
selfHandleResponse: true,
|
|
67
|
+
configure: (proxy) => {
|
|
68
|
+
stripSecurityHeaders(proxy);
|
|
69
|
+
disableCompression(proxy);
|
|
70
|
+
rewriteAdminBody(proxy, editorTarget, editorUrl);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
await adminVite.listen();
|
|
77
|
+
return {
|
|
78
|
+
adminVite,
|
|
79
|
+
editorVite,
|
|
80
|
+
adminTarget,
|
|
81
|
+
editorTarget,
|
|
82
|
+
adminUrl,
|
|
83
|
+
editorUrl,
|
|
84
|
+
adminPort,
|
|
85
|
+
editorPort,
|
|
86
|
+
async close() {
|
|
87
|
+
try {
|
|
88
|
+
await adminVite.close();
|
|
89
|
+
}
|
|
90
|
+
catch { /* ignore */ }
|
|
91
|
+
try {
|
|
92
|
+
await editorVite.close();
|
|
93
|
+
}
|
|
94
|
+
catch { /* ignore */ }
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function printProxyBanner(handle) {
|
|
99
|
+
console.log("");
|
|
100
|
+
console.log(chalk.green(` Admin proxied: ${handle.adminUrl} -> ${handle.adminTarget}`));
|
|
101
|
+
console.log(chalk.green(` Editor proxied: ${handle.editorUrl} -> ${handle.editorTarget}`));
|
|
102
|
+
console.log("");
|
|
103
|
+
console.log(chalk.cyan(" Open your admin panel:"));
|
|
104
|
+
console.log(chalk.yellow(` ${handle.adminUrl}/admin/storefront`));
|
|
105
|
+
console.log("");
|
|
106
|
+
}
|
|
107
|
+
export async function promptForStore() {
|
|
108
|
+
const answer = await inquirer.prompt([
|
|
109
|
+
{
|
|
110
|
+
type: "input",
|
|
111
|
+
name: "store",
|
|
112
|
+
message: "Which store do you want to proxy? (e.g. 'storename' for storename.myikas.com)",
|
|
113
|
+
validate: (v) => v && /^[a-z0-9-]+$/i.test(v)
|
|
114
|
+
? true
|
|
115
|
+
: "Store name must be non-empty alphanumeric (dashes allowed)"
|
|
116
|
+
}
|
|
117
|
+
]);
|
|
118
|
+
return answer.store;
|
|
119
|
+
}
|
|
120
|
+
export function resolveEnvironmentDefaults(dev) {
|
|
121
|
+
return dev
|
|
122
|
+
? { editorUrl: DEV_EDITOR_URL, adminDomain: DEV_ADMIN_DOMAIN }
|
|
123
|
+
: { editorUrl: PROD_EDITOR_URL, adminDomain: PROD_ADMIN_DOMAIN };
|
|
124
|
+
}
|
|
125
|
+
export function createProxyCommand() {
|
|
126
|
+
const command = new Command("proxy");
|
|
127
|
+
command
|
|
128
|
+
.description("Run localhost proxies for the ikas admin panel + editor so local code components can connect without HTTPS/mixed-content issues")
|
|
129
|
+
.option("-s, --store <name>", "Store name (e.g. 'storename' for storename.myikas.com)")
|
|
130
|
+
.option("-p, --port <port>", `Admin port (default: ${DEFAULT_ADMIN_PORT})`, String(DEFAULT_ADMIN_PORT))
|
|
131
|
+
.option("--editor-port <port>", `Editor port (default: ${DEFAULT_EDITOR_PORT})`, String(DEFAULT_EDITOR_PORT))
|
|
132
|
+
.option("--dev", "Use ikas dev environment (.myikas.dev + studio-dev.ikasapps.com) instead of prod")
|
|
133
|
+
.option("-e, --editor <url>", "Override editor URL to proxy")
|
|
134
|
+
.option("-d, --domain <domain>", "Override admin domain suffix")
|
|
135
|
+
.action(async (opts) => {
|
|
136
|
+
const storeName = opts.store || (await promptForStore());
|
|
137
|
+
const envDefaults = resolveEnvironmentDefaults(Boolean(opts.dev));
|
|
138
|
+
const handle = await startProxy({
|
|
139
|
+
store: storeName,
|
|
140
|
+
adminPort: Number(opts.port) || DEFAULT_ADMIN_PORT,
|
|
141
|
+
editorPort: Number(opts.editorPort) || DEFAULT_EDITOR_PORT,
|
|
142
|
+
editorUrl: opts.editor || envDefaults.editorUrl,
|
|
143
|
+
adminDomain: opts.domain || envDefaults.adminDomain
|
|
144
|
+
});
|
|
145
|
+
printProxyBanner(handle);
|
|
146
|
+
console.log(chalk.gray(" Keep `ikas-component dev` running in another terminal for the WS server."));
|
|
147
|
+
});
|
|
148
|
+
return command;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Strip headers that prevent the proxied pages from running in an HTTP context
|
|
152
|
+
* (e.g. strict CSPs, framing rules). We need this because the admin/editor are
|
|
153
|
+
* normally loaded over HTTPS and may ship headers that are hostile to being
|
|
154
|
+
* served over http://localhost.
|
|
155
|
+
*/
|
|
156
|
+
function stripSecurityHeaders(proxy) {
|
|
157
|
+
proxy.on("proxyRes", (proxyRes) => {
|
|
158
|
+
delete proxyRes.headers["content-security-policy"];
|
|
159
|
+
delete proxyRes.headers["content-security-policy-report-only"];
|
|
160
|
+
delete proxyRes.headers["strict-transport-security"];
|
|
161
|
+
delete proxyRes.headers["cross-origin-opener-policy"];
|
|
162
|
+
delete proxyRes.headers["cross-origin-embedder-policy"];
|
|
163
|
+
delete proxyRes.headers["cross-origin-resource-policy"];
|
|
164
|
+
delete proxyRes.headers["x-frame-options"];
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Force identity encoding so response bodies arrive uncompressed and can be
|
|
169
|
+
* string-rewritten. Without this, admin responses come back gzip/brotli and
|
|
170
|
+
* the rewriter below would corrupt them.
|
|
171
|
+
*/
|
|
172
|
+
function disableCompression(proxy) {
|
|
173
|
+
proxy.on("proxyReq", (proxyReq) => {
|
|
174
|
+
proxyReq.setHeader("accept-encoding", "identity");
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* For text responses from the admin target, swap the deployed editor origin
|
|
179
|
+
* with the local editor proxy URL so the iframe src in the admin's bundled JS
|
|
180
|
+
* points at localhost instead of the HTTPS origin. That keeps everything on
|
|
181
|
+
* http://localhost, which is what unblocks ws://localhost:5201.
|
|
182
|
+
*/
|
|
183
|
+
function rewriteAdminBody(proxy, fromUrl, toUrl) {
|
|
184
|
+
proxy.on("proxyRes", (proxyRes, _req, res) => {
|
|
185
|
+
const contentType = String(proxyRes.headers["content-type"] || "");
|
|
186
|
+
const isText = /text\/|application\/(javascript|json|xml|xhtml)/i.test(contentType);
|
|
187
|
+
for (const [k, v] of Object.entries(proxyRes.headers)) {
|
|
188
|
+
if (k.toLowerCase() === "content-length")
|
|
189
|
+
continue;
|
|
190
|
+
if (v !== undefined)
|
|
191
|
+
res.setHeader(k, v);
|
|
192
|
+
}
|
|
193
|
+
res.statusCode = proxyRes.statusCode || 200;
|
|
194
|
+
if (!isText) {
|
|
195
|
+
proxyRes.pipe(res);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const chunks = [];
|
|
199
|
+
proxyRes.on("data", (c) => chunks.push(c));
|
|
200
|
+
proxyRes.on("end", () => {
|
|
201
|
+
let body = Buffer.concat(chunks).toString("utf8");
|
|
202
|
+
body = body.split(fromUrl).join(toUrl);
|
|
203
|
+
const out = Buffer.from(body, "utf8");
|
|
204
|
+
res.setHeader("content-length", String(out.length));
|
|
205
|
+
res.end(out);
|
|
206
|
+
});
|
|
207
|
+
proxyRes.on("error", () => res.end());
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=proxy.js.map
|