@fluid-app/fluid-cli-widget 0.1.23 → 0.1.25
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/README.md +1 -1
- package/dist/index.d.mts +31 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +67 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/templates/default/package.json.template +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ fluid widget status
|
|
|
16
16
|
fluid widget logs
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
- `fluid widget create <project-name>` — scaffold a standalone widget package
|
|
19
|
+
- `fluid widget create <project-name>` — scaffold a standalone worker-only widget package from the bundled canonical template. Pass `--remote-template` only to opt into the GitHub mirror, or `--skip-install` for scaffold-only output.
|
|
20
20
|
- `fluid widget link` — link the current project to an existing Droplet and package name.
|
|
21
21
|
- `pnpm dev` — run the generated project's local Remote DOM development endpoints.
|
|
22
22
|
- `fluid widget build` — validate and build runtime artifacts into `.fluid/widget-dist`.
|
package/dist/index.d.mts
CHANGED
|
@@ -21,11 +21,8 @@ interface WidgetCreateOptions {
|
|
|
21
21
|
readonly droplet?: string;
|
|
22
22
|
/** Initial widget package version written into manifest.ts. */
|
|
23
23
|
readonly packageVersion?: string;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
* template instead. Implied by `--local`. Useful offline or in tests.
|
|
27
|
-
*/
|
|
28
|
-
readonly skipRemoteTemplate?: boolean;
|
|
24
|
+
/** Explicitly use the GitHub starter instead of the bundled template. */
|
|
25
|
+
readonly remoteTemplate?: boolean;
|
|
29
26
|
}
|
|
30
27
|
interface WidgetLinkOptions {
|
|
31
28
|
readonly droplet?: string;
|
|
@@ -56,12 +53,39 @@ declare const buildCommand: Command;
|
|
|
56
53
|
interface CloneCommandOptions {
|
|
57
54
|
readonly droplet?: string;
|
|
58
55
|
readonly dir?: string;
|
|
56
|
+
readonly skipInstall?: boolean;
|
|
59
57
|
}
|
|
60
58
|
declare const cloneCommand: Command;
|
|
61
59
|
//#endregion
|
|
60
|
+
//#region src/utils/package-manager.d.ts
|
|
61
|
+
declare function installDependencies(cwd: string): Promise<void>;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils/github-template.d.ts
|
|
64
|
+
interface GithubTemplateVariables {
|
|
65
|
+
readonly projectName: string;
|
|
66
|
+
readonly widgetScope: string;
|
|
67
|
+
readonly widgetPackageVersion: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Clone the GitHub widget template into `targetPath`, strip its git history,
|
|
71
|
+
* and rewrite the baked defaults to the user's values. The repo holds a fully
|
|
72
|
+
* rendered project (no `{{placeholders}}`), so we do targeted, deterministic
|
|
73
|
+
* replacements of the known defaults rather than template interpolation.
|
|
74
|
+
*
|
|
75
|
+
* Returns true on success. Returns false (never throws) when the template
|
|
76
|
+
* couldn't be fetched — git missing, offline, repo unavailable. The caller
|
|
77
|
+
* reports that requested-template failure. The partially-cloned target is
|
|
78
|
+
* cleaned up before returning false.
|
|
79
|
+
*/
|
|
80
|
+
declare function tryFetchGithubTemplate(targetPath: string, variables: GithubTemplateVariables): Promise<boolean>;
|
|
81
|
+
//#endregion
|
|
62
82
|
//#region src/commands/create.d.ts
|
|
83
|
+
interface CreateWidgetProjectDependencies {
|
|
84
|
+
readonly installDependencies: typeof installDependencies;
|
|
85
|
+
readonly tryFetchGithubTemplate: typeof tryFetchGithubTemplate;
|
|
86
|
+
}
|
|
63
87
|
declare const createCommand: Command;
|
|
64
|
-
declare function createWidgetProject(projectName: string, options: WidgetCreateOptions): Promise<void>;
|
|
88
|
+
declare function createWidgetProject(projectName: string, options: WidgetCreateOptions, dependencies?: CreateWidgetProjectDependencies): Promise<void>;
|
|
65
89
|
//#endregion
|
|
66
90
|
//#region src/commands/push.d.ts
|
|
67
91
|
interface PushCommandOptions {
|
|
@@ -208,5 +232,5 @@ declare function formatValidationErrors(errors: readonly WidgetCliValidationErro
|
|
|
208
232
|
declare const widgetCommand: Command;
|
|
209
233
|
declare const plugin: FluidPlugin;
|
|
210
234
|
//#endregion
|
|
211
|
-
export { type BuildWidgetOptions, type BuildWidgetPackageOptions, type BuildWidgetPackageResult, type CloneCommandOptions, DEFAULT_WIDGET_DEV_PORT, DEFAULT_WIDGET_OUT_DIR, type FluidWidgetConfig, type LoadedWidgetConfig, type LogsCommandOptions, type PublishCommandOptions, type PublishWidgetPackageDependencies, type PublishWidgetPackageOptions, type PublishWidgetPackageResult, type PushCommandOptions, ROOT_WIDGET_CONFIG_FILE, type StatusCommandOptions, type ValidateWidgetOptions, WIDGET_CONFIG_FILE, WIDGET_DEV_ROUTES, type WidgetCliValidationError, type WidgetCommandOptions, type WidgetCreateOptions, type WidgetDevOptions, type WidgetDevProjectSummary, type WidgetLinkOptions, type WidgetTemplateVariables, WidgetValidationError, type WidgetValidationResult, buildCommand, buildViteDevArgs, buildWidgetPackage, cloneCommand, createCommand, createWidgetProject, plugin as default, devCommand, formatValidationErrors, formatValidationSuccess, formatWidgetConfig, linkCommand, loadWidgetConfig, logsCommand, mergeWidgetConfig, parseWidgetConfigSource, printWidgetDevSummary, publishCommand, publishWidgetPackage, pushCommand, resolveWidgetConfigPath, resolveWidgetDevProject, resolveWidgetSourceConfig, runViteDevServer, statusCommand, validateCommand, validateDropletUuid, validateDropletWidgetProject, widgetCommand, withRootWidgetConfigBridge, writeWidgetConfig };
|
|
235
|
+
export { type BuildWidgetOptions, type BuildWidgetPackageOptions, type BuildWidgetPackageResult, type CloneCommandOptions, type CreateWidgetProjectDependencies, DEFAULT_WIDGET_DEV_PORT, DEFAULT_WIDGET_OUT_DIR, type FluidWidgetConfig, type LoadedWidgetConfig, type LogsCommandOptions, type PublishCommandOptions, type PublishWidgetPackageDependencies, type PublishWidgetPackageOptions, type PublishWidgetPackageResult, type PushCommandOptions, ROOT_WIDGET_CONFIG_FILE, type StatusCommandOptions, type ValidateWidgetOptions, WIDGET_CONFIG_FILE, WIDGET_DEV_ROUTES, type WidgetCliValidationError, type WidgetCommandOptions, type WidgetCreateOptions, type WidgetDevOptions, type WidgetDevProjectSummary, type WidgetLinkOptions, type WidgetTemplateVariables, WidgetValidationError, type WidgetValidationResult, buildCommand, buildViteDevArgs, buildWidgetPackage, cloneCommand, createCommand, createWidgetProject, plugin as default, devCommand, formatValidationErrors, formatValidationSuccess, formatWidgetConfig, linkCommand, loadWidgetConfig, logsCommand, mergeWidgetConfig, parseWidgetConfigSource, printWidgetDevSummary, publishCommand, publishWidgetPackage, pushCommand, resolveWidgetConfigPath, resolveWidgetDevProject, resolveWidgetSourceConfig, runViteDevServer, statusCommand, validateCommand, validateDropletUuid, validateDropletWidgetProject, widgetCommand, withRootWidgetConfigBridge, writeWidgetConfig };
|
|
212
236
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/commands/build.ts","../src/commands/clone.ts","../src/commands/create.ts","../src/commands/push.ts","../src/commands/dev.ts","../src/commands/link.ts","../src/commands/logs.ts","../src/commands/publish.ts","../src/commands/status.ts","../src/commands/validate.ts","../src/utils/config.ts","../src/utils/source-package.ts","../src/utils/validation.ts","../src/index.ts"],"mappings":";;;;;UAAiB,uBAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;EAAA,SACA,oBAAA;EAAA,SACA,UAAA;EAAA,SACA,gBAAA;EAAA,SACA,eAAA;EAAA,SACA,gBAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,mBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;;WAEA,cAAA;EAVA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/commands/build.ts","../src/commands/clone.ts","../src/utils/package-manager.ts","../src/utils/github-template.ts","../src/commands/create.ts","../src/commands/push.ts","../src/commands/dev.ts","../src/commands/link.ts","../src/commands/logs.ts","../src/commands/publish.ts","../src/commands/status.ts","../src/commands/validate.ts","../src/utils/config.ts","../src/utils/source-package.ts","../src/utils/validation.ts","../src/index.ts"],"mappings":";;;;;UAAiB,uBAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;EAAA,SACA,oBAAA;EAAA,SACA,UAAA;EAAA,SACA,gBAAA;EAAA,SACA,eAAA;EAAA,SACA,gBAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,mBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;;WAEA,cAAA;EAVA;EAAA,SAYA,cAAA;AAAA;AAAA,UAGM,iBAAA;EAAA,SACN,OAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,GAAA;AAAA;;;UCbM,kBAAA;EAAA,SACN,MAAA;EAAA,SACA,aAAA;AAAA;AAAA,UAGM,yBAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA;EAAA,SACA,aAAA;AAAA;AAAA,UAGM,wBAAA;EAAA,SACN,MAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;AAAA;AAAA,iBAGW,kBAAA,CACpB,OAAA,EAAS,yBAAA,GACR,OAAA,CAAQ,wBAAA;AAAA,cAoCE,YAAA,EAAc,OAAA;;;UCjDV,mBAAA;EAAA,SACN,OAAA;EAAA,SACA,GAAA;EAAA,SACA,WAAA;AAAA;AAAA,cAGE,YAAA,EAAc,OAAA;;;iBCVL,mBAAA,CAAoB,GAAA,WAAc,OAAA;;;UCoBvC,uBAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;EAAA,SACA,oBAAA;AAAA;;;;;;AJjBX;;;;;AAIA;iBI2BsB,sBAAA,CACpB,UAAA,UACA,SAAA,EAAW,uBAAA,GACV,OAAA;;;UC5Bc,+BAAA;EAAA,SACN,mBAAA,SAA4B,mBAAA;EAAA,SAC5B,sBAAA,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AA,EAAW,2BAAA;AAAA;AAAA,cAGT,qBAAA,SAA8B,KAAA;EAAA,SACzB,MAAA,WAAiB,4BAAA;EAEjC,WAAA,CAAY,MAAA,WAAiB,4BAAA;AAAA;AAAA,iBAOT,4BAAA,CACpB,UAAA,UACA,kBAAA,YACC,OAAA,CAAQ,sBAAA;AAAA,iBA+DW,0BAAA,GAAA,CACpB,UAAA,UACA,QAAA,QAAgB,OAAA,CAAQ,CAAA,GACxB,kBAAA,YACC,OAAA,CAAQ,CAAA;AAAA,iBA+DK,yBAAA,CACd,UAAA;EAAA,SACY,IAAA;EAAA,SAAuB,YAAA;AAAA;AAAA,iBASrB,uBAAA,CACd,MAAA,EAAQ,sBAAA;;;UC5LO,wBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;AAAA;AAAA,iBAGK,sBAAA,CACd,MAAA,WAAiB,wBAAA;;;cCON,aAAA,EAAe,OAAA;AAAA,cAetB,MAAA,EAAQ,WAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1174,7 +1174,7 @@ function writeWidgetMarker(dir, marker) {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
//#endregion
|
|
1176
1176
|
//#region src/commands/clone.ts
|
|
1177
|
-
const cloneCommand = new Command("clone").description("Clone a widget package's git repository (mints a fresh token per call)").argument("<package>", "Widget package key to clone").option("--droplet <uuid>", "Droplet UUID that owns the package (defaults to the company-owned package)").option("--dir <dir>", "Target directory (defaults to ./<package>/)").action((packageKey, options) => runCliAction(async () => {
|
|
1177
|
+
const cloneCommand = new Command("clone").description("Clone a widget package's git repository (mints a fresh token per call)").argument("<package>", "Widget package key to clone").option("--droplet <uuid>", "Droplet UUID that owns the package (defaults to the company-owned package)").option("--dir <dir>", "Target directory (defaults to ./<package>/)").option("--skip-install", "Skip dependency installation").action((packageKey, options) => runCliAction(async () => {
|
|
1178
1178
|
const trimmedPackage = packageKey.trim();
|
|
1179
1179
|
if (!trimmedPackage) throw new Error("A widget package key is required.");
|
|
1180
1180
|
const droplet = options.droplet?.trim();
|
|
@@ -1219,10 +1219,27 @@ const cloneCommand = new Command("clone").description("Clone a widget package's
|
|
|
1219
1219
|
...droplet ? { droplet } : {}
|
|
1220
1220
|
});
|
|
1221
1221
|
spinner.succeed(`Cloned into ${chalk.cyan(targetDir)}`);
|
|
1222
|
+
const installCommand = getInstallCommand(targetDir);
|
|
1223
|
+
if (options.skipInstall !== true) {
|
|
1224
|
+
spinner.start(`Installing dependencies with ${installCommand}...`);
|
|
1225
|
+
try {
|
|
1226
|
+
await installDependencies(targetDir);
|
|
1227
|
+
spinner.succeed("Installed dependencies");
|
|
1228
|
+
} catch {
|
|
1229
|
+
spinner.fail("Failed to install dependencies");
|
|
1230
|
+
console.log();
|
|
1231
|
+
console.log(chalk.yellow("You can install dependencies manually:"));
|
|
1232
|
+
console.log(chalk.cyan(` ${installCommand}`));
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1222
1235
|
console.log(chalk.dim(` cd ${path.relative(process.cwd(), targetDir) || "."}`));
|
|
1236
|
+
if (options.skipInstall === true) console.log(chalk.dim(` ${installCommand}`));
|
|
1223
1237
|
}));
|
|
1224
1238
|
//#endregion
|
|
1225
1239
|
//#region src/utils/template.ts
|
|
1240
|
+
const EMBEDDED_PORTAL_SDK_VERSION = "0.1.460";
|
|
1241
|
+
const EMBEDDED_CLI_CORE_VERSION = "0.1.14";
|
|
1242
|
+
const EMBEDDED_CLI_WIDGET_VERSION = "0.1.25";
|
|
1226
1243
|
function getDefaultTemplatePath() {
|
|
1227
1244
|
return path.join(findPackageRoot(), "templates", "default");
|
|
1228
1245
|
}
|
|
@@ -1245,27 +1262,32 @@ async function copyWidgetTemplate(templatePath, targetPath, variables) {
|
|
|
1245
1262
|
for (const skillFile of await getSharedTemplateSkillFiles()) await writeOutputFiles(targetPath, getOutputFilenames(skillFile.relativePath), skillFile.content);
|
|
1246
1263
|
}
|
|
1247
1264
|
async function getPortalSdkVersion(options = {}) {
|
|
1248
|
-
return getWorkspacePackageVersion(["portal", "sdk"],
|
|
1265
|
+
return getWorkspacePackageVersion(["portal", "sdk"], EMBEDDED_PORTAL_SDK_VERSION, options);
|
|
1249
1266
|
}
|
|
1250
1267
|
async function getPortalCoreVersion(options = {}) {
|
|
1251
|
-
return getWorkspacePackageVersion(["portal", "core"],
|
|
1268
|
+
return getWorkspacePackageVersion(["portal", "core"], void 0, options);
|
|
1252
1269
|
}
|
|
1253
1270
|
async function getCliVersion(options = {}) {
|
|
1254
|
-
return getWorkspacePackageVersion(["cli", "core"],
|
|
1271
|
+
return getWorkspacePackageVersion(["cli", "core"], EMBEDDED_CLI_CORE_VERSION, options);
|
|
1255
1272
|
}
|
|
1256
1273
|
async function getWidgetCliVersion(options = {}) {
|
|
1257
|
-
return getWorkspacePackageVersion(["cli", "widget"],
|
|
1274
|
+
return getWorkspacePackageVersion(["cli", "widget"], EMBEDDED_CLI_WIDGET_VERSION, options);
|
|
1258
1275
|
}
|
|
1259
|
-
async function getWorkspacePackageVersion(packagePathSegments,
|
|
1276
|
+
async function getWorkspacePackageVersion(packagePathSegments, embeddedVersion, options) {
|
|
1260
1277
|
try {
|
|
1261
1278
|
const packageRoot = findPackageRoot();
|
|
1262
1279
|
const packagesRoot = path.join(packageRoot, "..", "..");
|
|
1263
1280
|
const targetPackageRoot = path.join(packagesRoot, ...packagePathSegments);
|
|
1264
1281
|
if (options.local) return `link:${(options.targetPath ? path.relative(options.targetPath, targetPackageRoot) : targetPackageRoot).replace(/\\/g, "/") || "."}`;
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1282
|
+
if (embeddedVersion) return embeddedVersion;
|
|
1283
|
+
const packageJsonPath = path.join(targetPackageRoot, "package.json");
|
|
1284
|
+
const content = await readFile(packageJsonPath, "utf-8");
|
|
1285
|
+
const pkg = JSON.parse(content);
|
|
1286
|
+
if (typeof pkg.version !== "string") throw new Error(`Missing version in ${packageJsonPath}`);
|
|
1287
|
+
return pkg.version;
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
if (embeddedVersion) return embeddedVersion;
|
|
1290
|
+
throw new Error(`Could not resolve the exact template package version for ${packagePathSegments.join("/")}`, { cause: error });
|
|
1269
1291
|
}
|
|
1270
1292
|
}
|
|
1271
1293
|
async function getFiles(dir, baseDir = dir) {
|
|
@@ -1370,8 +1392,8 @@ const TEMPLATE_DEFAULTS = {
|
|
|
1370
1392
|
* replacements of the known defaults rather than template interpolation.
|
|
1371
1393
|
*
|
|
1372
1394
|
* Returns true on success. Returns false (never throws) when the template
|
|
1373
|
-
* couldn't be fetched — git missing, offline, repo unavailable
|
|
1374
|
-
*
|
|
1395
|
+
* couldn't be fetched — git missing, offline, repo unavailable. The caller
|
|
1396
|
+
* reports that requested-template failure. The partially-cloned target is
|
|
1375
1397
|
* cleaned up before returning false.
|
|
1376
1398
|
*/
|
|
1377
1399
|
async function tryFetchGithubTemplate(targetPath, variables) {
|
|
@@ -1439,7 +1461,11 @@ async function replaceInFile(filePath, replacements) {
|
|
|
1439
1461
|
//#region src/commands/create.ts
|
|
1440
1462
|
const DEFAULT_WIDGET_PACKAGE_VERSION = "0.1.0";
|
|
1441
1463
|
const DEFAULT_WIDGET_SCOPE = "droplet";
|
|
1442
|
-
const
|
|
1464
|
+
const defaultCreateWidgetProjectDependencies = {
|
|
1465
|
+
installDependencies,
|
|
1466
|
+
tryFetchGithubTemplate
|
|
1467
|
+
};
|
|
1468
|
+
const createCommand = new Command("create").description("Create a standalone Fluid widget project").argument("<project-name>", "Name of the widget project to create").option("--skip-install", "Create the scaffold only; skip dependency installation").option("-o, --output-dir <dir>", "Directory to create the project in (defaults to cwd)").option("--scope <scope>", "Widget package scope/namespace", DEFAULT_WIDGET_SCOPE).option("--package-version <version>", "Initial widget package version", DEFAULT_WIDGET_PACKAGE_VERSION).option("--local", "Use local monorepo packages via file: links (for development testing)").option("--remote-template", "Use the GitHub starter template instead of the bundled template").option("--droplet <uuid>", "Existing droplet UUID that owns the package").action(async (projectName, options) => {
|
|
1443
1469
|
try {
|
|
1444
1470
|
await createWidgetProject(projectName, options);
|
|
1445
1471
|
} catch (err) {
|
|
@@ -1449,7 +1475,7 @@ const createCommand = new Command("create").description("Create a standalone Flu
|
|
|
1449
1475
|
process.exit(1);
|
|
1450
1476
|
}
|
|
1451
1477
|
});
|
|
1452
|
-
async function createWidgetProject(projectName, options) {
|
|
1478
|
+
async function createWidgetProject(projectName, options, dependencies = defaultCreateWidgetProjectDependencies) {
|
|
1453
1479
|
console.log();
|
|
1454
1480
|
console.log(chalk.bold("Creating a new Fluid widget project"));
|
|
1455
1481
|
console.log();
|
|
@@ -1464,7 +1490,7 @@ async function createWidgetProject(projectName, options) {
|
|
|
1464
1490
|
const targetPath = path.join(outputDir, projectName);
|
|
1465
1491
|
if (await directoryExists(targetPath)) throw new Error(`Directory already exists: ${targetPath}`);
|
|
1466
1492
|
const templatePath = getDefaultTemplatePath();
|
|
1467
|
-
if (!await directoryExists(templatePath)) throw new Error("Default widget template not found.");
|
|
1493
|
+
if (options.remoteTemplate !== true && !await directoryExists(templatePath)) throw new Error("Default widget template not found.");
|
|
1468
1494
|
const config = mergeWidgetConfig({}, { droplet });
|
|
1469
1495
|
const widgetScope = options.scope ?? DEFAULT_WIDGET_SCOPE;
|
|
1470
1496
|
const localOptions = {
|
|
@@ -1481,17 +1507,21 @@ async function createWidgetProject(projectName, options) {
|
|
|
1481
1507
|
fluidCliVersion: await getCliVersion(localOptions),
|
|
1482
1508
|
widgetCliVersion: await getWidgetCliVersion(localOptions)
|
|
1483
1509
|
};
|
|
1484
|
-
|
|
1510
|
+
if (options.local === true && options.remoteTemplate === true) throw new Error("--remote-template cannot be combined with --local");
|
|
1511
|
+
const useRemoteTemplate = options.remoteTemplate === true;
|
|
1485
1512
|
let scaffolded = false;
|
|
1486
1513
|
if (useRemoteTemplate) {
|
|
1487
1514
|
const remoteSpinner = ora("Fetching widget template from GitHub...").start();
|
|
1488
|
-
scaffolded = await tryFetchGithubTemplate(targetPath, {
|
|
1515
|
+
scaffolded = await dependencies.tryFetchGithubTemplate(targetPath, {
|
|
1489
1516
|
projectName,
|
|
1490
1517
|
widgetScope,
|
|
1491
1518
|
widgetPackageVersion: options.packageVersion ?? DEFAULT_WIDGET_PACKAGE_VERSION
|
|
1492
1519
|
});
|
|
1493
1520
|
if (scaffolded) remoteSpinner.succeed("Fetched widget template from GitHub");
|
|
1494
|
-
else
|
|
1521
|
+
else {
|
|
1522
|
+
remoteSpinner.fail("Failed to fetch the GitHub widget template");
|
|
1523
|
+
throw new Error("Couldn't fetch the requested GitHub template. Remove --remote-template to use the bundled template.");
|
|
1524
|
+
}
|
|
1495
1525
|
}
|
|
1496
1526
|
const spinner = ora(scaffolded ? "Finalizing widget project..." : "Copying widget template...").start();
|
|
1497
1527
|
try {
|
|
@@ -1506,17 +1536,23 @@ async function createWidgetProject(projectName, options) {
|
|
|
1506
1536
|
if (options.skipInstall !== true) {
|
|
1507
1537
|
spinner.start(`Installing dependencies with ${installCommand}...`);
|
|
1508
1538
|
try {
|
|
1509
|
-
await installDependencies(targetPath);
|
|
1539
|
+
await dependencies.installDependencies(targetPath);
|
|
1510
1540
|
spinner.succeed("Installed dependencies");
|
|
1511
|
-
} catch {
|
|
1541
|
+
} catch (error) {
|
|
1512
1542
|
spinner.fail("Failed to install dependencies");
|
|
1513
1543
|
console.log();
|
|
1514
|
-
console.log(chalk.yellow(
|
|
1544
|
+
console.log(chalk.yellow(`The scaffold was retained at ${targetPath}.`));
|
|
1545
|
+
console.log(chalk.yellow("Install dependencies manually to continue:"));
|
|
1515
1546
|
console.log(chalk.cyan(` cd ${formatCdPath(targetPath)}`));
|
|
1516
1547
|
console.log(chalk.cyan(` ${installCommand}`));
|
|
1548
|
+
throw error;
|
|
1517
1549
|
}
|
|
1518
1550
|
}
|
|
1519
1551
|
console.log();
|
|
1552
|
+
if (options.skipInstall === true) {
|
|
1553
|
+
console.log(chalk.yellow("Scaffold only: dependencies were not installed and must be installed before development."));
|
|
1554
|
+
console.log();
|
|
1555
|
+
}
|
|
1520
1556
|
console.log(chalk.green.bold("Success!") + ` Created ${chalk.cyan(projectName)}`);
|
|
1521
1557
|
console.log();
|
|
1522
1558
|
console.log("Next steps:");
|
|
@@ -1591,8 +1627,16 @@ function printWidgetDevSummary(summary) {
|
|
|
1591
1627
|
console.log();
|
|
1592
1628
|
}
|
|
1593
1629
|
async function runViteDevServer(projectDir, options = {}) {
|
|
1594
|
-
|
|
1595
|
-
if (!viteCliPath)
|
|
1630
|
+
let viteCliPath = resolveViteCliPath(projectDir);
|
|
1631
|
+
if (!viteCliPath) {
|
|
1632
|
+
const installCommand = getInstallCommand(projectDir);
|
|
1633
|
+
console.log(chalk.yellow(`Vite is not installed yet — running ${installCommand} first...`));
|
|
1634
|
+
try {
|
|
1635
|
+
await installDependencies(projectDir);
|
|
1636
|
+
} catch {}
|
|
1637
|
+
viteCliPath = resolveViteCliPath(projectDir);
|
|
1638
|
+
}
|
|
1639
|
+
if (!viteCliPath) throw new Error(`Unable to find Vite in node_modules. Run \`${getInstallCommand(projectDir)}\` in ${projectDir}, then retry.`);
|
|
1596
1640
|
await runNodeScript(viteCliPath, buildViteDevArgs(options), projectDir);
|
|
1597
1641
|
}
|
|
1598
1642
|
function resolveViteCliPath(projectDir) {
|