@seed-design/cli 0.0.0-alpha → 0.0.0-alpha-20241004093556
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/bin/index.mjs +482 -2
- package/package.json +1 -1
- package/src/utils/get-metadata.ts +1 -1
package/bin/index.mjs
CHANGED
|
@@ -1,3 +1,483 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
// src/utils/get-config.ts
|
|
4
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var MODULE_NAME = "seed-design";
|
|
8
|
+
var explorer = cosmiconfig(MODULE_NAME, {
|
|
9
|
+
searchPlaces: [`${MODULE_NAME}.json`]
|
|
10
|
+
});
|
|
11
|
+
var rawConfigSchema = z.object({
|
|
12
|
+
$schema: z.string().optional(),
|
|
13
|
+
rsc: z.coerce.boolean().default(false),
|
|
14
|
+
tsx: z.coerce.boolean().default(true),
|
|
15
|
+
css: z.coerce.boolean().default(true),
|
|
16
|
+
path: z.string()
|
|
17
|
+
}).strict();
|
|
18
|
+
var configSchema = rawConfigSchema.extend({
|
|
19
|
+
resolvedUIPaths: z.string()
|
|
20
|
+
});
|
|
21
|
+
async function getConfig(cwd) {
|
|
22
|
+
const config = await getRawConfig(cwd);
|
|
23
|
+
if (!config) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return await resolveConfigPaths(cwd, config);
|
|
27
|
+
}
|
|
28
|
+
async function resolveConfigPaths(cwd, config) {
|
|
29
|
+
const seedComponentRootPath = path.resolve(cwd, config.path);
|
|
30
|
+
return configSchema.parse({
|
|
31
|
+
...config,
|
|
32
|
+
resolvedUIPaths: path.join(seedComponentRootPath, "ui")
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async function getRawConfig(cwd) {
|
|
36
|
+
try {
|
|
37
|
+
const configResult = await explorer.search(cwd);
|
|
38
|
+
if (!configResult) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return rawConfigSchema.parse(configResult.config);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.log(error);
|
|
44
|
+
throw new Error(`Invalid configuration found in ${cwd}/seed-design.json.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/schema.ts
|
|
49
|
+
import { z as z2 } from "zod";
|
|
50
|
+
var componentMetadataSchema = z2.object({
|
|
51
|
+
name: z2.string(),
|
|
52
|
+
description: z2.string().optional(),
|
|
53
|
+
dependencies: z2.array(z2.string()).optional(),
|
|
54
|
+
devDependencies: z2.array(z2.string()).optional(),
|
|
55
|
+
innerDependencies: z2.array(z2.string()).optional(),
|
|
56
|
+
snippets: z2.array(z2.string()),
|
|
57
|
+
type: z2.enum(["component"])
|
|
58
|
+
});
|
|
59
|
+
var componentMetadataIndexSchema = z2.array(componentMetadataSchema);
|
|
60
|
+
var omittedComponentMetadataIndexSchema = componentMetadataSchema.omit({ snippets: true });
|
|
61
|
+
var componentMetadataSchemaWithRegistry = omittedComponentMetadataIndexSchema.extend({
|
|
62
|
+
registries: z2.array(
|
|
63
|
+
z2.object({
|
|
64
|
+
name: z2.string(),
|
|
65
|
+
content: z2.string()
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
});
|
|
69
|
+
var componentMetadataWithRegistrySchema = z2.array(componentMetadataSchemaWithRegistry);
|
|
70
|
+
|
|
71
|
+
// src/utils/get-metadata.ts
|
|
72
|
+
var BASE_URL = false ? "https://component.seed-design.io" : "http://localhost:3000";
|
|
73
|
+
async function fetchComponentMetadatas(fileNames) {
|
|
74
|
+
try {
|
|
75
|
+
const results = await Promise.all(
|
|
76
|
+
fileNames.map(async (fileName) => {
|
|
77
|
+
const response = await fetch(`${BASE_URL}/registry/component/${fileName}.json`);
|
|
78
|
+
return await response.json();
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
return results;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.log(error);
|
|
84
|
+
throw new Error(`Failed to fetch registry from ${BASE_URL}.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function getMetadataIndex() {
|
|
88
|
+
try {
|
|
89
|
+
const [result] = await fetchComponentMetadatas(["index"]);
|
|
90
|
+
return componentMetadataIndexSchema.parse(result);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.log(error);
|
|
93
|
+
throw new Error(`Failed to fetch components from ${BASE_URL}.`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/utils/get-package-manager.ts
|
|
98
|
+
import { detect } from "@antfu/ni";
|
|
99
|
+
async function getPackageManager(targetDir) {
|
|
100
|
+
const packageManager = await detect({ programmatic: true, cwd: targetDir });
|
|
101
|
+
if (packageManager === "yarn@berry")
|
|
102
|
+
return "yarn";
|
|
103
|
+
if (packageManager === "pnpm@6")
|
|
104
|
+
return "pnpm";
|
|
105
|
+
if (packageManager === "bun")
|
|
106
|
+
return "bun";
|
|
107
|
+
return packageManager ?? "npm";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/utils/transformers/index.ts
|
|
111
|
+
import { promises as fs } from "fs";
|
|
112
|
+
import { tmpdir } from "os";
|
|
113
|
+
import path2 from "path";
|
|
114
|
+
|
|
115
|
+
// src/utils/transformers/transform-jsx.ts
|
|
116
|
+
import { transformFromAstSync } from "@babel/core";
|
|
117
|
+
import transformTypescript from "@babel/plugin-transform-typescript";
|
|
118
|
+
import * as recast from "recast";
|
|
119
|
+
import { parse as parse2 } from "@babel/parser";
|
|
120
|
+
var PARSE_OPTIONS = {
|
|
121
|
+
sourceType: "module",
|
|
122
|
+
allowImportExportEverywhere: true,
|
|
123
|
+
allowReturnOutsideFunction: true,
|
|
124
|
+
startLine: 1,
|
|
125
|
+
tokens: true,
|
|
126
|
+
plugins: [
|
|
127
|
+
"asyncGenerators",
|
|
128
|
+
"bigInt",
|
|
129
|
+
"classPrivateMethods",
|
|
130
|
+
"classPrivateProperties",
|
|
131
|
+
"classProperties",
|
|
132
|
+
"classStaticBlock",
|
|
133
|
+
"decimal",
|
|
134
|
+
"decorators-legacy",
|
|
135
|
+
"doExpressions",
|
|
136
|
+
"dynamicImport",
|
|
137
|
+
"exportDefaultFrom",
|
|
138
|
+
"exportNamespaceFrom",
|
|
139
|
+
"functionBind",
|
|
140
|
+
"functionSent",
|
|
141
|
+
"importAssertions",
|
|
142
|
+
"importMeta",
|
|
143
|
+
"nullishCoalescingOperator",
|
|
144
|
+
"numericSeparator",
|
|
145
|
+
"objectRestSpread",
|
|
146
|
+
"optionalCatchBinding",
|
|
147
|
+
"optionalChaining",
|
|
148
|
+
[
|
|
149
|
+
"pipelineOperator",
|
|
150
|
+
{
|
|
151
|
+
proposal: "minimal"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
"recordAndTuple",
|
|
156
|
+
{
|
|
157
|
+
syntaxType: "hash"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"throwExpressions",
|
|
161
|
+
"topLevelAwait",
|
|
162
|
+
"v8intrinsic",
|
|
163
|
+
"typescript",
|
|
164
|
+
"jsx"
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
var transformJsx = async ({ sourceFile, config }) => {
|
|
168
|
+
const output = sourceFile.getFullText();
|
|
169
|
+
if (config.tsx) {
|
|
170
|
+
return output;
|
|
171
|
+
}
|
|
172
|
+
const ast = recast.parse(output, {
|
|
173
|
+
parser: {
|
|
174
|
+
parse: (code) => {
|
|
175
|
+
return parse2(code, PARSE_OPTIONS);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const result = transformFromAstSync(ast, output, {
|
|
180
|
+
cloneInputAst: false,
|
|
181
|
+
code: false,
|
|
182
|
+
ast: true,
|
|
183
|
+
plugins: [transformTypescript],
|
|
184
|
+
configFile: false
|
|
185
|
+
});
|
|
186
|
+
if (!result || !result.ast) {
|
|
187
|
+
throw new Error("Failed to transform JSX");
|
|
188
|
+
}
|
|
189
|
+
return recast.print(result.ast).code;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// src/utils/transformers/transform-rsc.ts
|
|
193
|
+
import { SyntaxKind } from "ts-morph";
|
|
194
|
+
var transformRsc = async ({ sourceFile, config }) => {
|
|
195
|
+
if (config.rsc) {
|
|
196
|
+
return sourceFile;
|
|
197
|
+
}
|
|
198
|
+
const first = sourceFile.getFirstChildByKind(SyntaxKind.ExpressionStatement);
|
|
199
|
+
if (first?.getText() === `"use client";`) {
|
|
200
|
+
first.remove();
|
|
201
|
+
}
|
|
202
|
+
return sourceFile;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/utils/transformers/transform-css.ts
|
|
206
|
+
var transformCSS = async ({ sourceFile, config }) => {
|
|
207
|
+
if (config.css) {
|
|
208
|
+
return sourceFile;
|
|
209
|
+
}
|
|
210
|
+
const imports = sourceFile.getImportDeclarations();
|
|
211
|
+
const cssImports = imports.filter((i) => i.getModuleSpecifierValue().endsWith(".css"));
|
|
212
|
+
for (const cssImport of cssImports) {
|
|
213
|
+
cssImport.remove();
|
|
214
|
+
}
|
|
215
|
+
return sourceFile;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/utils/transformers/index.ts
|
|
219
|
+
import { Project, ScriptKind } from "ts-morph";
|
|
220
|
+
var transformers = [transformRsc, transformCSS];
|
|
221
|
+
var project = new Project({
|
|
222
|
+
compilerOptions: {}
|
|
223
|
+
});
|
|
224
|
+
async function createTempSourceFile(filename) {
|
|
225
|
+
const dir = await fs.mkdtemp(path2.join(tmpdir(), "seed-deisgn-"));
|
|
226
|
+
return path2.join(dir, filename);
|
|
227
|
+
}
|
|
228
|
+
async function transform(opts) {
|
|
229
|
+
const tempFile = await createTempSourceFile(opts.filename);
|
|
230
|
+
const sourceFile = project.createSourceFile(tempFile, opts.raw, {
|
|
231
|
+
scriptKind: ScriptKind.TSX
|
|
232
|
+
});
|
|
233
|
+
for (const transformer of transformers) {
|
|
234
|
+
transformer({ sourceFile, ...opts });
|
|
235
|
+
}
|
|
236
|
+
return await transformJsx({
|
|
237
|
+
sourceFile,
|
|
238
|
+
...opts
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/commands/add.ts
|
|
243
|
+
import * as p from "@clack/prompts";
|
|
244
|
+
import { execa } from "execa";
|
|
245
|
+
import fs2 from "fs-extra";
|
|
246
|
+
import path3 from "path";
|
|
247
|
+
import color from "picocolors";
|
|
248
|
+
import { z as z3 } from "zod";
|
|
249
|
+
|
|
250
|
+
// src/utils/add-relative-components.ts
|
|
251
|
+
function addRelativeComponents(userSelects, metadataIndex) {
|
|
252
|
+
const selectedComponents = /* @__PURE__ */ new Set();
|
|
253
|
+
function addSeedDependencies(componentName) {
|
|
254
|
+
if (selectedComponents.has(componentName))
|
|
255
|
+
return;
|
|
256
|
+
selectedComponents.add(componentName);
|
|
257
|
+
const component = metadataIndex.find((c) => c.name === componentName);
|
|
258
|
+
if (!component)
|
|
259
|
+
return;
|
|
260
|
+
if (component.innerDependencies) {
|
|
261
|
+
for (const dep of component.innerDependencies) {
|
|
262
|
+
addSeedDependencies(dep);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const componentName of userSelects) {
|
|
267
|
+
addSeedDependencies(componentName);
|
|
268
|
+
}
|
|
269
|
+
return Array.from(selectedComponents);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// src/commands/add.ts
|
|
273
|
+
var addOptionsSchema = z3.object({
|
|
274
|
+
components: z3.array(z3.string()).optional(),
|
|
275
|
+
cwd: z3.string(),
|
|
276
|
+
all: z3.boolean()
|
|
277
|
+
// yes: z.boolean(),
|
|
278
|
+
// overwrite: z.boolean(),
|
|
279
|
+
// path: z.string().optional(),
|
|
280
|
+
});
|
|
281
|
+
var addCommand = (cli) => {
|
|
282
|
+
cli.command("add [...components]", "add component").option("-a, --all", "Add all components", {
|
|
283
|
+
default: false
|
|
284
|
+
}).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", {
|
|
285
|
+
default: process.cwd()
|
|
286
|
+
}).example("seed-design add box-button").example("seed-design add alert-dialog").action(async (components, opts) => {
|
|
287
|
+
const options = addOptionsSchema.parse({
|
|
288
|
+
components,
|
|
289
|
+
...opts
|
|
290
|
+
});
|
|
291
|
+
const highlight = (text2) => color.cyan(text2);
|
|
292
|
+
const cwd = options.cwd;
|
|
293
|
+
if (!fs2.existsSync(cwd)) {
|
|
294
|
+
p.log.error(`The path ${cwd} does not exist. Please try again.`);
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
297
|
+
const metadataIndex = await getMetadataIndex();
|
|
298
|
+
let selectedComponents = options.all ? metadataIndex.map((meatadata) => meatadata.name) : options.components;
|
|
299
|
+
if (!options.components?.length && !options.all) {
|
|
300
|
+
const selects = await p.multiselect({
|
|
301
|
+
message: "Select all components to add",
|
|
302
|
+
options: metadataIndex.map((metadata) => {
|
|
303
|
+
return {
|
|
304
|
+
label: metadata.name,
|
|
305
|
+
value: metadata.name,
|
|
306
|
+
hint: metadata.description
|
|
307
|
+
};
|
|
308
|
+
})
|
|
309
|
+
});
|
|
310
|
+
if (p.isCancel(selects)) {
|
|
311
|
+
p.log.error("Aborted.");
|
|
312
|
+
process.exit(0);
|
|
313
|
+
}
|
|
314
|
+
selectedComponents = selects;
|
|
315
|
+
}
|
|
316
|
+
if (!selectedComponents?.length) {
|
|
317
|
+
p.log.error("No components found.");
|
|
318
|
+
process.exit(0);
|
|
319
|
+
}
|
|
320
|
+
const allComponents = addRelativeComponents(selectedComponents, metadataIndex);
|
|
321
|
+
const addedComponents = allComponents.filter((c) => !selectedComponents.includes(c));
|
|
322
|
+
const config = await getConfig(cwd);
|
|
323
|
+
const metadatas = await fetchComponentMetadatas(allComponents);
|
|
324
|
+
p.log.message(`Selection: ${highlight(selectedComponents.join(", "))}`);
|
|
325
|
+
if (addedComponents.length) {
|
|
326
|
+
p.log.message(
|
|
327
|
+
`Inner Dependencies: ${highlight(addedComponents.join(", "))} will be also added.`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
for (const metadata of metadatas) {
|
|
331
|
+
for (const registry of metadata.registries) {
|
|
332
|
+
const UIFolderPath = config.resolvedUIPaths;
|
|
333
|
+
if (!fs2.existsSync(UIFolderPath)) {
|
|
334
|
+
await fs2.mkdir(UIFolderPath, { recursive: true });
|
|
335
|
+
}
|
|
336
|
+
let filePath = path3.resolve(UIFolderPath, registry.name);
|
|
337
|
+
const content = await transform({
|
|
338
|
+
filename: registry.name,
|
|
339
|
+
config,
|
|
340
|
+
raw: registry.content
|
|
341
|
+
});
|
|
342
|
+
if (!config.tsx) {
|
|
343
|
+
filePath = filePath.replace(/\.tsx$/, ".jsx");
|
|
344
|
+
filePath = filePath.replace(/\.ts$/, ".js");
|
|
345
|
+
}
|
|
346
|
+
await fs2.writeFile(filePath, content);
|
|
347
|
+
const relativePath = path3.relative(cwd, filePath);
|
|
348
|
+
p.log.info(`Added ${highlight(registry.name)} to ${highlight(relativePath)}`);
|
|
349
|
+
}
|
|
350
|
+
const packageManager = await getPackageManager(cwd);
|
|
351
|
+
const { start, stop } = p.spinner();
|
|
352
|
+
if (metadata.dependencies?.length) {
|
|
353
|
+
start(color.gray("Installing dependencies"));
|
|
354
|
+
const result = await execa(
|
|
355
|
+
packageManager,
|
|
356
|
+
[packageManager === "npm" ? "install" : "add", ...metadata.dependencies],
|
|
357
|
+
{
|
|
358
|
+
cwd
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
if (result.failed) {
|
|
362
|
+
console.error(result.all);
|
|
363
|
+
process.exit(1);
|
|
364
|
+
} else {
|
|
365
|
+
for (const deps of metadata.dependencies) {
|
|
366
|
+
p.log.info(`- ${deps}`);
|
|
367
|
+
}
|
|
368
|
+
stop("Dependencies installed.");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (metadata.devDependencies?.length) {
|
|
372
|
+
start(color.gray("Installing devDependencies"));
|
|
373
|
+
const result = await execa(
|
|
374
|
+
packageManager,
|
|
375
|
+
[packageManager === "npm" ? "install" : "add", "-D", ...metadata.devDependencies],
|
|
376
|
+
{
|
|
377
|
+
cwd
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
if (result.failed) {
|
|
381
|
+
console.error(result.all);
|
|
382
|
+
process.exit(1);
|
|
383
|
+
} else {
|
|
384
|
+
for (const deps of metadata.devDependencies) {
|
|
385
|
+
p.log.info(`- ${deps}`);
|
|
386
|
+
}
|
|
387
|
+
stop("Dependencies installed.");
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
p.outro("Components added.");
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// src/utils/get-package-info.ts
|
|
396
|
+
import findup from "findup-sync";
|
|
397
|
+
import fs3 from "fs-extra";
|
|
398
|
+
var PACKAGE_JSON = "package.json";
|
|
399
|
+
function getPackagePath() {
|
|
400
|
+
const packageJsonPath = findup(PACKAGE_JSON);
|
|
401
|
+
if (!packageJsonPath) {
|
|
402
|
+
throw new Error("No package.json file found in the project.");
|
|
403
|
+
}
|
|
404
|
+
return packageJsonPath;
|
|
405
|
+
}
|
|
406
|
+
function getPackageInfo() {
|
|
407
|
+
return fs3.readJSONSync(getPackagePath());
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/index.ts
|
|
411
|
+
import { cac } from "cac";
|
|
412
|
+
|
|
413
|
+
// src/commands/init.ts
|
|
414
|
+
import * as p2 from "@clack/prompts";
|
|
415
|
+
import fs4 from "fs-extra";
|
|
416
|
+
import path4 from "path";
|
|
417
|
+
import color2 from "picocolors";
|
|
418
|
+
import { z as z4 } from "zod";
|
|
419
|
+
var initOptionsSchema = z4.object({
|
|
420
|
+
cwd: z4.string()
|
|
421
|
+
});
|
|
422
|
+
var initCommand = (cli) => {
|
|
423
|
+
cli.command("init", "initialize seed-design.json").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", {
|
|
424
|
+
default: process.cwd()
|
|
425
|
+
}).action(async (opts) => {
|
|
426
|
+
const options = initOptionsSchema.parse({ ...opts });
|
|
427
|
+
const highlight = (text2) => color2.cyan(text2);
|
|
428
|
+
const group2 = await p2.group(
|
|
429
|
+
{
|
|
430
|
+
tsx: () => p2.confirm({
|
|
431
|
+
message: `Would you like to use ${highlight("TypeScript")} (recommended)?`,
|
|
432
|
+
initialValue: true
|
|
433
|
+
}),
|
|
434
|
+
rsc: () => p2.confirm({
|
|
435
|
+
message: `Are you using ${highlight("React Server Components")}?`,
|
|
436
|
+
initialValue: false
|
|
437
|
+
}),
|
|
438
|
+
css: () => p2.confirm({
|
|
439
|
+
message: `Would you like to use ${highlight("CSS Modules")}? (If true, CSS import will be added in components)`,
|
|
440
|
+
initialValue: true
|
|
441
|
+
}),
|
|
442
|
+
path: () => p2.text({
|
|
443
|
+
message: `Enter the path to your ${highlight("seed-design directory")}`,
|
|
444
|
+
initialValue: "./seed-design",
|
|
445
|
+
defaultValue: "./seed-design",
|
|
446
|
+
placeholder: "./seed-design"
|
|
447
|
+
})
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
onCancel: () => {
|
|
451
|
+
p2.cancel("Operation cancelled.");
|
|
452
|
+
process.exit(0);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
const config = {
|
|
457
|
+
rsc: group2.rsc,
|
|
458
|
+
tsx: group2.tsx,
|
|
459
|
+
css: group2.css,
|
|
460
|
+
path: group2.path
|
|
461
|
+
};
|
|
462
|
+
const { start, stop } = p2.spinner();
|
|
463
|
+
start("Writing seed-design.json...");
|
|
464
|
+
const targetPath = path4.resolve(options.cwd, "seed-design.json");
|
|
465
|
+
await fs4.writeFile(targetPath, `${JSON.stringify(config, null, 2)}
|
|
466
|
+
`, "utf-8");
|
|
467
|
+
const relativePath = path4.relative(process.cwd(), targetPath);
|
|
468
|
+
stop(`seed-design.json written to ${highlight(relativePath)}`);
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// src/index.ts
|
|
473
|
+
var NAME = "seed-design";
|
|
474
|
+
var CLI = cac(NAME);
|
|
475
|
+
async function main() {
|
|
476
|
+
const packageInfo = getPackageInfo();
|
|
477
|
+
addCommand(CLI);
|
|
478
|
+
initCommand(CLI);
|
|
479
|
+
CLI.version(packageInfo.version || "1.0.0", "-v, --version");
|
|
480
|
+
CLI.help();
|
|
481
|
+
CLI.parse();
|
|
482
|
+
}
|
|
483
|
+
main();
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "@/src/schema";
|
|
5
5
|
|
|
6
6
|
const BASE_URL =
|
|
7
|
-
process.env.NODE_ENV === "prod" ? "https://component-
|
|
7
|
+
process.env.NODE_ENV === "prod" ? "https://component.seed-design.io" : "http://localhost:3000";
|
|
8
8
|
|
|
9
9
|
export async function fetchComponentMetadatas(
|
|
10
10
|
fileNames?: string[],
|