@stencil/cli 5.0.0-alpha.8 → 5.0.0-alpha.9
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/index.d.mts +9 -0
- package/dist/index.mjs +167 -50
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -188,6 +188,15 @@ interface WizardContext {
|
|
|
188
188
|
nypm: typeof import('nypm');
|
|
189
189
|
/** Resolved project config. See {@link ProjectConfig} for available fields. */
|
|
190
190
|
config: ProjectConfig;
|
|
191
|
+
/**
|
|
192
|
+
* Absolute path to the monorepo workspace root when the project is part of a
|
|
193
|
+
* workspace, `undefined` for single-package projects.
|
|
194
|
+
*
|
|
195
|
+
* When present, `config.rootDir` is the core Stencil package (e.g.
|
|
196
|
+
* `<workspaceRoot>/packages/core/`). The plugin is responsible for deciding
|
|
197
|
+
* where in the workspace it wants to live and for creating that directory.
|
|
198
|
+
*/
|
|
199
|
+
workspaceRoot?: string;
|
|
191
200
|
}
|
|
192
201
|
/**
|
|
193
202
|
* A single file a plugin can offer during `stencil generate`.
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { LOG_LEVELS } from "@stencil/core/compiler";
|
|
2
2
|
import { buildError, catchError, hasError, isFunction, isOutputTargetDocs, isOutputTargetSsr, isOutputTargetWww, isString, normalizePath, readOnlyArrayHasStringMember, result, shouldIgnoreError, toCamelCase, validateComponentTag } from "@stencil/core/compiler/utils";
|
|
3
|
-
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
3
|
import { basename, dirname, join, parse, relative, resolve } from "node:path";
|
|
4
|
+
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
import { cancel, isCancel, select } from "@clack/prompts";
|
|
7
7
|
import * as nypm from "nypm";
|
|
8
|
-
import { addDevDependency, installDependencies } from "nypm";
|
|
8
|
+
import { addDevDependency, detectPackageManager, installDependencies } from "nypm";
|
|
9
9
|
import { isCI } from "std-env";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
|
+
import { homedir } from "node:os";
|
|
12
13
|
import { dirname as dirname$1, isAbsolute, join as join$1, relative as relative$1 } from "path";
|
|
13
14
|
import ts from "typescript";
|
|
14
15
|
import { generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getStyleBoilerplate, getTemplatePath, toPascalCase } from "@stencil/templates";
|
|
@@ -647,13 +648,16 @@ async function discoverPlugins(rootDir, loader = (url) => import(url)) {
|
|
|
647
648
|
if (!pkg) return [];
|
|
648
649
|
const depNames = [...new Set([...Object.keys(toStringRecord(pkg.dependencies)), ...Object.keys(toStringRecord(pkg.devDependencies))])];
|
|
649
650
|
const plugins = (await Promise.allSettled(depNames.map((name) => loadOne(rootDir, name, loader)))).filter((r) => r.status === "fulfilled" && r.value !== null).map((r) => r.value);
|
|
650
|
-
const
|
|
651
|
-
if (
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
651
|
+
const devEnv = process.env.STENCIL_WIZARD_DEV;
|
|
652
|
+
if (devEnv) {
|
|
653
|
+
const devPaths = devEnv.split(",").map((s) => s.trim()).filter(Boolean);
|
|
654
|
+
for (const devPath of devPaths) {
|
|
655
|
+
const devPlugin = await loadDevPlugin(resolve(rootDir, devPath), loader);
|
|
656
|
+
if (devPlugin) {
|
|
657
|
+
const idx = plugins.findIndex((p) => p.packageName === devPlugin.packageName);
|
|
658
|
+
if (idx >= 0) plugins.splice(idx, 1, devPlugin);
|
|
659
|
+
else plugins.unshift(devPlugin);
|
|
660
|
+
}
|
|
657
661
|
}
|
|
658
662
|
}
|
|
659
663
|
return plugins;
|
|
@@ -719,7 +723,8 @@ const KNOWN_INTEGRATIONS = [
|
|
|
719
723
|
package: "@stencil/sass",
|
|
720
724
|
displayName: "Sass",
|
|
721
725
|
description: "Sass/SCSS styles",
|
|
722
|
-
group: "Styling"
|
|
726
|
+
group: "Styling",
|
|
727
|
+
requiresStencilConfig: true
|
|
723
728
|
},
|
|
724
729
|
{
|
|
725
730
|
package: "@stencil/eslint-plugin",
|
|
@@ -737,25 +742,29 @@ const KNOWN_INTEGRATIONS = [
|
|
|
737
742
|
package: "@stencil/types-output-target",
|
|
738
743
|
displayName: "Types",
|
|
739
744
|
description: "TypeScript types for React, Vue, Solid, Svelte, Preact",
|
|
740
|
-
group: "Framework integrations"
|
|
745
|
+
group: "Framework integrations",
|
|
746
|
+
requiresStencilConfig: true
|
|
741
747
|
},
|
|
742
748
|
{
|
|
743
749
|
package: "@stencil/react-output-target",
|
|
744
750
|
displayName: "React",
|
|
745
751
|
description: "React component wrappers",
|
|
746
|
-
group: "Framework integrations"
|
|
752
|
+
group: "Framework integrations",
|
|
753
|
+
requiresStencilConfig: true
|
|
747
754
|
},
|
|
748
755
|
{
|
|
749
756
|
package: "@stencil/angular-output-target",
|
|
750
757
|
displayName: "Angular",
|
|
751
758
|
description: "Angular component wrappers",
|
|
752
|
-
group: "Framework integrations"
|
|
759
|
+
group: "Framework integrations",
|
|
760
|
+
requiresStencilConfig: true
|
|
753
761
|
},
|
|
754
762
|
{
|
|
755
763
|
package: "@stencil/vue-output-target",
|
|
756
764
|
displayName: "Vue",
|
|
757
765
|
description: "Vue component wrappers",
|
|
758
|
-
group: "Framework integrations"
|
|
766
|
+
group: "Framework integrations",
|
|
767
|
+
requiresStencilConfig: true
|
|
759
768
|
}
|
|
760
769
|
];
|
|
761
770
|
async function promptOutputs() {
|
|
@@ -843,7 +852,6 @@ async function promptDocs() {
|
|
|
843
852
|
hint: "vscode-data.json - editor autocomplete for your components"
|
|
844
853
|
}
|
|
845
854
|
],
|
|
846
|
-
initialValues: ["cem"],
|
|
847
855
|
required: false
|
|
848
856
|
});
|
|
849
857
|
cancelIfAborted(picks);
|
|
@@ -887,6 +895,29 @@ async function promptIntegrations() {
|
|
|
887
895
|
cancelIfAborted(picks);
|
|
888
896
|
return KNOWN_INTEGRATIONS.filter((i) => picks.includes(i.package));
|
|
889
897
|
}
|
|
898
|
+
function hasFrameworkTargets(integrations) {
|
|
899
|
+
return integrations.some((i) => i.group === "Framework integrations");
|
|
900
|
+
}
|
|
901
|
+
function needsStencilConfig(integrations) {
|
|
902
|
+
return integrations.some((i) => i.requiresStencilConfig);
|
|
903
|
+
}
|
|
904
|
+
async function promptMonorepo() {
|
|
905
|
+
const answer = await p.confirm({
|
|
906
|
+
message: "Set up as a monorepo workspace? (recommended for publishing framework wrappers)",
|
|
907
|
+
initialValue: true
|
|
908
|
+
});
|
|
909
|
+
cancelIfAborted(answer);
|
|
910
|
+
return answer;
|
|
911
|
+
}
|
|
912
|
+
async function promptWorkspaceCoreName() {
|
|
913
|
+
const name = await p.text({
|
|
914
|
+
message: "Core package directory name:",
|
|
915
|
+
defaultValue: "core",
|
|
916
|
+
placeholder: "core"
|
|
917
|
+
});
|
|
918
|
+
cancelIfAborted(name);
|
|
919
|
+
return name || "core";
|
|
920
|
+
}
|
|
890
921
|
/**
|
|
891
922
|
* Prompt for actions on an existing project: install new integrations and/or
|
|
892
923
|
* run init wizards for already-installed packages with wizard contributions.
|
|
@@ -958,6 +989,27 @@ function defaultProjectConfig(rootDir, overrides) {
|
|
|
958
989
|
};
|
|
959
990
|
}
|
|
960
991
|
/**
|
|
992
|
+
* Walk up from `startDir` looking for a monorepo workspace root — a directory
|
|
993
|
+
* containing `pnpm-workspace.yaml` or a `package.json` with a `workspaces` field.
|
|
994
|
+
* Stops at the home directory or filesystem root. Returns `undefined` if none found.
|
|
995
|
+
* @param startDir The directory to start searching from.
|
|
996
|
+
* @returns A promise that resolves to the workspace root directory, or undefined if none found.
|
|
997
|
+
*/
|
|
998
|
+
async function detectWorkspaceRoot(startDir) {
|
|
999
|
+
const home = homedir();
|
|
1000
|
+
let dir = startDir;
|
|
1001
|
+
while (true) {
|
|
1002
|
+
if (existsSync(join(dir, "pnpm-workspace.yaml"))) return dir;
|
|
1003
|
+
try {
|
|
1004
|
+
const pkg = JSON.parse(await readFile(join(dir, "package.json"), "utf8"));
|
|
1005
|
+
if (Array.isArray(pkg.workspaces)) return dir;
|
|
1006
|
+
} catch {}
|
|
1007
|
+
const parent = dirname(dir);
|
|
1008
|
+
if (parent === dir || dir === home) return void 0;
|
|
1009
|
+
dir = parent;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
961
1013
|
* Returns true if the directory looks like an existing Stencil project:
|
|
962
1014
|
* - has an explicit `stencil.config.ts`, OR
|
|
963
1015
|
* - has `.tsx` files under `src/` (zero-config project).
|
|
@@ -977,7 +1029,7 @@ async function isExistingStencilProject(dir) {
|
|
|
977
1029
|
}
|
|
978
1030
|
//#endregion
|
|
979
1031
|
//#region src/wizard/splash.ts
|
|
980
|
-
const CLI_VERSION = "5.0.0-alpha.
|
|
1032
|
+
const CLI_VERSION = "5.0.0-alpha.9";
|
|
981
1033
|
const isTTY = process.stdout.isTTY;
|
|
982
1034
|
const noColor = !isTTY || "NO_COLOR" in process.env;
|
|
983
1035
|
const RESET = noColor ? "" : "\x1B[0m";
|
|
@@ -1087,7 +1139,8 @@ async function taskAdd(packages, strictConfig) {
|
|
|
1087
1139
|
isNewProject: false,
|
|
1088
1140
|
prompts: p,
|
|
1089
1141
|
nypm,
|
|
1090
|
-
config: strictConfig ? toProjectConfig(strictConfig) : defaultProjectConfig(cwd)
|
|
1142
|
+
config: strictConfig ? toProjectConfig(strictConfig) : defaultProjectConfig(cwd),
|
|
1143
|
+
workspaceRoot: await detectWorkspaceRoot(cwd)
|
|
1091
1144
|
};
|
|
1092
1145
|
if (packagesToInstall.length > 0) {
|
|
1093
1146
|
const discovered = await discoverPlugins(cwd);
|
|
@@ -3529,20 +3582,22 @@ const taskInfo = (coreCompiler, sys, logger) => {
|
|
|
3529
3582
|
* @param rootDir - Destination directory (typically `process.cwd()`).
|
|
3530
3583
|
* @param projectName - Value to substitute for `{{PROJECT_NAME}}` placeholders.
|
|
3531
3584
|
* @param namespace - Value to substitute for `{{NAMESPACE}}` placeholders.
|
|
3585
|
+
* @param stencilVersion - Optional version to substitute for `{{STENCIL_VERSION}}` placeholders.
|
|
3532
3586
|
*/
|
|
3533
|
-
async function copyTemplate(rootDir, projectName, namespace) {
|
|
3587
|
+
async function copyTemplate(rootDir, projectName, namespace, stencilVersion) {
|
|
3534
3588
|
const templateDir = getTemplatePath("component-starter");
|
|
3535
3589
|
const entries = await readdir(templateDir, {
|
|
3536
3590
|
recursive: true,
|
|
3537
3591
|
withFileTypes: true
|
|
3538
3592
|
});
|
|
3593
|
+
const resolvedStencilVersion = stencilVersion ? `^${stencilVersion}` : "^5.0.0";
|
|
3539
3594
|
for (const entry of entries) {
|
|
3540
3595
|
if (!entry.isFile()) continue;
|
|
3541
3596
|
const srcPath = join(entry.parentPath, entry.name);
|
|
3542
3597
|
const relPath = relative(templateDir, srcPath);
|
|
3543
3598
|
const destPath = join(rootDir, relPath);
|
|
3544
3599
|
await mkdir(dirname(destPath), { recursive: true });
|
|
3545
|
-
const content = (await readFile(srcPath, "utf8")).replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{NAMESPACE\}\}/g, namespace);
|
|
3600
|
+
const content = (await readFile(srcPath, "utf8")).replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{NAMESPACE\}\}/g, namespace).replace(/\{\{STENCIL_VERSION\}\}/g, resolvedStencilVersion);
|
|
3546
3601
|
if (relPath === "package.json") await mergePackageJson(destPath, content);
|
|
3547
3602
|
else if (relPath === "tsconfig.json") await mergeTsConfig(destPath, content);
|
|
3548
3603
|
else if (relPath === ".gitignore") await mergeGitignore(destPath, content);
|
|
@@ -3630,6 +3685,53 @@ async function writeGlobalScript(rootDir) {
|
|
|
3630
3685
|
await mkdir(dirname(path), { recursive: true });
|
|
3631
3686
|
await writeIfAbsent(path, `export default function (): void {}\n`);
|
|
3632
3687
|
}
|
|
3688
|
+
function workspaceBuildScript(pm) {
|
|
3689
|
+
switch (pm) {
|
|
3690
|
+
case "pnpm": return "pnpm -r build";
|
|
3691
|
+
case "yarn": return "yarn workspaces run build";
|
|
3692
|
+
case "bun": return "bun run --filter \"*\" build";
|
|
3693
|
+
default: return "npm run build --workspaces --if-present";
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
/**
|
|
3697
|
+
* Scaffold a workspace root in `cwd`: creates `packages/`, writes the appropriate
|
|
3698
|
+
* workspace manifest (`pnpm-workspace.yaml` for pnpm, `workspaces` field in
|
|
3699
|
+
* `package.json` for npm / yarn / bun), and ensures a root `package.json` exists.
|
|
3700
|
+
* @param cwd - Absolute path to the workspace root (where `package.json` will be created).
|
|
3701
|
+
* @param projectName - Name to use for the root package.json (typically the project name).
|
|
3702
|
+
* @returns A promise that resolves when the workspace root has been scaffolded.
|
|
3703
|
+
*/
|
|
3704
|
+
async function scaffoldWorkspaceRoot(cwd, projectName) {
|
|
3705
|
+
await mkdir(join(cwd, "packages"), { recursive: true });
|
|
3706
|
+
const pm = await detectPackageManager(cwd);
|
|
3707
|
+
const usePnpmYaml = pm?.name === "pnpm";
|
|
3708
|
+
const pkgPath = join(cwd, "package.json");
|
|
3709
|
+
let pkg;
|
|
3710
|
+
try {
|
|
3711
|
+
pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
3712
|
+
} catch {
|
|
3713
|
+
pkg = {};
|
|
3714
|
+
}
|
|
3715
|
+
pkg.name ??= `${projectName}-workspace`;
|
|
3716
|
+
pkg.version ??= "0.0.1";
|
|
3717
|
+
pkg.private = true;
|
|
3718
|
+
pkg.scripts ??= { build: workspaceBuildScript(pm?.name) };
|
|
3719
|
+
if (!usePnpmYaml) pkg.workspaces = ["packages/*"];
|
|
3720
|
+
delete pkg.dependencies;
|
|
3721
|
+
delete pkg.devDependencies;
|
|
3722
|
+
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
3723
|
+
if (usePnpmYaml) {
|
|
3724
|
+
const yamlPath = join(cwd, "pnpm-workspace.yaml");
|
|
3725
|
+
try {
|
|
3726
|
+
await writeFile(yamlPath, `packages:\n - 'packages/*'\n`, {
|
|
3727
|
+
encoding: "utf8",
|
|
3728
|
+
flag: "wx"
|
|
3729
|
+
});
|
|
3730
|
+
} catch (e) {
|
|
3731
|
+
if (e.code !== "EEXIST") throw e;
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3633
3735
|
/**
|
|
3634
3736
|
* Write output-driven distributable fields (type, module, types) into package.json.
|
|
3635
3737
|
* These fields depend on which outputs the user selected, so they cannot be static in the template.
|
|
@@ -3662,7 +3764,7 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3662
3764
|
const isExistingProject = await isExistingStencilProject(cwd);
|
|
3663
3765
|
printSplash();
|
|
3664
3766
|
p.intro(`stencil init`);
|
|
3665
|
-
if (process.env.STENCIL_WIZARD_DEV) p.log.warn(`Dev mode: loading
|
|
3767
|
+
if (process.env.STENCIL_WIZARD_DEV) p.log.warn(`Dev mode: loading wizards from ${process.env.STENCIL_WIZARD_DEV}`);
|
|
3666
3768
|
if (isCI) {
|
|
3667
3769
|
p.log.warn("Running in CI - non-interactive mode is not yet supported for `stencil init`.");
|
|
3668
3770
|
process.exit(1);
|
|
@@ -3677,33 +3779,39 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3677
3779
|
const features = await promptFeatures();
|
|
3678
3780
|
const docs = await promptDocs();
|
|
3679
3781
|
const selectedIntegrations = await promptIntegrations();
|
|
3782
|
+
let monorepo = false;
|
|
3783
|
+
let coreName = "";
|
|
3784
|
+
if (hasFrameworkTargets(selectedIntegrations)) {
|
|
3785
|
+
monorepo = await promptMonorepo();
|
|
3786
|
+
if (monorepo) coreName = await promptWorkspaceCoreName();
|
|
3787
|
+
}
|
|
3680
3788
|
const configSource = generateStencilConfig({
|
|
3681
3789
|
namespace,
|
|
3682
3790
|
outputs,
|
|
3683
3791
|
signals: features.signals,
|
|
3684
3792
|
docs
|
|
3685
|
-
});
|
|
3793
|
+
}) ?? (needsStencilConfig(selectedIntegrations) ? `import { Config } from '@stencil/core';\n\nexport const config: Config = {\n namespace: '${namespace}',\n outputTargets: [{ type: 'loader-bundle' }],\n};\n` : null);
|
|
3686
3794
|
const summaryLines = [
|
|
3687
3795
|
`Template: component-starter`,
|
|
3688
3796
|
`Name: ${projectName}`,
|
|
3689
3797
|
`Namespace: ${namespace}`,
|
|
3690
3798
|
`Config: ${configSource ? "stencil.config.ts" : "zero-config (loader default)"}`
|
|
3691
3799
|
];
|
|
3800
|
+
if (monorepo) {
|
|
3801
|
+
summaryLines.push(`Structure: monorepo workspace`);
|
|
3802
|
+
summaryLines.push(`Core: packages/${coreName}/`);
|
|
3803
|
+
}
|
|
3692
3804
|
if (selectedIntegrations.length > 0) summaryLines.push(`Add: ${selectedIntegrations.map((i) => i.displayName).join(", ")}`);
|
|
3693
3805
|
p.note(summaryLines.join("\n"), "Summary");
|
|
3694
|
-
const
|
|
3695
|
-
cancelIfAborted(confirmed);
|
|
3696
|
-
if (!confirmed) {
|
|
3697
|
-
p.cancel("Cancelled.");
|
|
3698
|
-
process.exit(0);
|
|
3699
|
-
}
|
|
3806
|
+
const coreDir = monorepo ? join(cwd, "packages", coreName) : cwd;
|
|
3700
3807
|
const s1 = p.spinner();
|
|
3701
3808
|
s1.start("Scaffolding project files");
|
|
3702
|
-
await
|
|
3703
|
-
await
|
|
3704
|
-
|
|
3705
|
-
if (
|
|
3706
|
-
if (features.
|
|
3809
|
+
if (monorepo) await scaffoldWorkspaceRoot(cwd, projectName);
|
|
3810
|
+
await copyTemplate(coreDir, projectName, namespace, coreCompiler?.version);
|
|
3811
|
+
await applyPackageJsonFields(coreDir, generatePackageJsonFields(outputs));
|
|
3812
|
+
if (configSource) await writeStencilConfig(coreDir, configSource);
|
|
3813
|
+
if (features.globalStyle) await writeGlobalStyle(coreDir);
|
|
3814
|
+
if (features.globalScript) await writeGlobalScript(coreDir);
|
|
3707
3815
|
s1.stop("Project files created");
|
|
3708
3816
|
const s2 = p.spinner();
|
|
3709
3817
|
s2.start("Installing dependencies");
|
|
@@ -3717,30 +3825,38 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3717
3825
|
const pkgs = selectedIntegrations.map((i) => i.package);
|
|
3718
3826
|
s3.start(`Installing ${pkgs.join(", ")}`);
|
|
3719
3827
|
await addDevDependency(pkgs, {
|
|
3720
|
-
cwd,
|
|
3828
|
+
cwd: coreDir,
|
|
3721
3829
|
silent: true
|
|
3722
3830
|
});
|
|
3723
3831
|
s3.stop("Integrations installed");
|
|
3724
3832
|
}
|
|
3725
3833
|
if (selectedIntegrations.length > 0) {
|
|
3726
|
-
const discovered = await discoverPlugins(
|
|
3834
|
+
const discovered = await discoverPlugins(coreDir);
|
|
3727
3835
|
const selectedPkgs = new Set(selectedIntegrations.map((i) => i.package));
|
|
3728
|
-
const resolvedValidated = loadProjectConfig ? await loadProjectConfig(
|
|
3729
|
-
rootDir:
|
|
3836
|
+
const resolvedValidated = loadProjectConfig && configSource ? await loadProjectConfig(join(coreDir, "stencil.config.ts")) : coreCompiler ? coreCompiler.validateConfig({
|
|
3837
|
+
rootDir: coreDir,
|
|
3730
3838
|
outputTargets: outputKeysToTargets(outputs),
|
|
3731
3839
|
...configSource ? { namespace } : {}
|
|
3732
3840
|
}, {}).config : null;
|
|
3733
|
-
const
|
|
3841
|
+
const projectConfig = resolvedValidated ? {
|
|
3842
|
+
...toProjectConfig(resolvedValidated),
|
|
3843
|
+
rootDir: coreDir
|
|
3844
|
+
} : defaultProjectConfig(coreDir, { namespace });
|
|
3845
|
+
for (const d of discovered) if (selectedPkgs.has(d.packageName) && d.plugin.init?.run) await d.plugin.init.run({
|
|
3734
3846
|
isNewProject: true,
|
|
3735
3847
|
prompts: p,
|
|
3736
3848
|
nypm,
|
|
3737
|
-
config:
|
|
3738
|
-
|
|
3739
|
-
|
|
3849
|
+
config: projectConfig,
|
|
3850
|
+
workspaceRoot: monorepo ? cwd : void 0
|
|
3851
|
+
});
|
|
3740
3852
|
}
|
|
3741
|
-
|
|
3853
|
+
const pm = (await nypm.detectPackageManager(cwd))?.name ?? "npm";
|
|
3854
|
+
const devDir = monorepo ? `packages/${coreName}` : null;
|
|
3855
|
+
const devCmd = `${pm} run dev`;
|
|
3856
|
+
p.outro(devDir ? `Your project is ready!\n cd ${devDir}\n ${devCmd}` : `Your project is ready! Run: ${devCmd}`);
|
|
3742
3857
|
}
|
|
3743
3858
|
async function addCapabilities(cwd, strictConfig) {
|
|
3859
|
+
const workspaceRoot = await detectWorkspaceRoot(cwd);
|
|
3744
3860
|
const raw = JSON.parse(await readFile(join(cwd, "package.json"), "utf8"));
|
|
3745
3861
|
const installed = new Set([...Object.keys(raw.dependencies ?? {}), ...Object.keys(raw.devDependencies ?? {})]);
|
|
3746
3862
|
const discovered = await discoverPlugins(cwd);
|
|
@@ -3779,13 +3895,14 @@ async function addCapabilities(cwd, strictConfig) {
|
|
|
3779
3895
|
const allDiscovered = toInstall.length > 0 ? await discoverPlugins(cwd) : discovered;
|
|
3780
3896
|
const newlyInstalledPkgs = new Set(toInstall.map((i) => i.package));
|
|
3781
3897
|
const toRun = [...allDiscovered.filter((d) => newlyInstalledPkgs.has(d.packageName)), ...toConfigure].filter((d) => d.plugin.init?.run);
|
|
3782
|
-
const
|
|
3898
|
+
const projectConfig = strictConfig ? toProjectConfig(strictConfig) : defaultProjectConfig(cwd);
|
|
3899
|
+
for (const d of toRun) await d.plugin.init.run({
|
|
3783
3900
|
isNewProject: false,
|
|
3784
3901
|
prompts: p,
|
|
3785
3902
|
nypm,
|
|
3786
|
-
config:
|
|
3787
|
-
|
|
3788
|
-
|
|
3903
|
+
config: projectConfig,
|
|
3904
|
+
workspaceRoot
|
|
3905
|
+
});
|
|
3789
3906
|
p.outro("Done! Run pnpm run dev to continue.");
|
|
3790
3907
|
}
|
|
3791
3908
|
function toNamespace(name) {
|
|
@@ -3855,11 +3972,11 @@ const run = async (init) => {
|
|
|
3855
3972
|
configPath: flags.config
|
|
3856
3973
|
});
|
|
3857
3974
|
let strictConfig;
|
|
3858
|
-
|
|
3859
|
-
|
|
3975
|
+
const foundConfigPath = !findConfigResults.isErr ? result.unwrap(findConfigResults).configPath : null;
|
|
3976
|
+
if (foundConfigPath) {
|
|
3860
3977
|
const loaded = await coreCompiler.loadConfig({
|
|
3861
|
-
config: { rootDir },
|
|
3862
|
-
configPath:
|
|
3978
|
+
config: { rootDir: dirname(foundConfigPath) },
|
|
3979
|
+
configPath: foundConfigPath,
|
|
3863
3980
|
logger,
|
|
3864
3981
|
sys
|
|
3865
3982
|
});
|
|
@@ -3869,7 +3986,7 @@ const run = async (init) => {
|
|
|
3869
3986
|
else {
|
|
3870
3987
|
const loadProjectConfig = async (configPath) => {
|
|
3871
3988
|
const loaded = await coreCompiler.loadConfig({
|
|
3872
|
-
config: { rootDir },
|
|
3989
|
+
config: { rootDir: configPath ? dirname(configPath) : rootDir },
|
|
3873
3990
|
configPath,
|
|
3874
3991
|
logger,
|
|
3875
3992
|
sys
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/cli",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
4
4
|
"description": "CLI for Stencil - Web component compiler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@clack/prompts": "^1.5.1",
|
|
41
41
|
"nypm": "^0.3.12",
|
|
42
42
|
"std-env": "^3.8.0",
|
|
43
|
-
"@stencil/templates": "5.0.0-alpha.
|
|
44
|
-
"@stencil/dev-server": "5.0.0-alpha.
|
|
43
|
+
"@stencil/templates": "5.0.0-alpha.8",
|
|
44
|
+
"@stencil/dev-server": "5.0.0-alpha.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"tsdown": ">=0.21.0 <1.0.0",
|
|
48
48
|
"typescript": ">4.0.0 <7.0.0",
|
|
49
49
|
"vitest": "^4.1.7",
|
|
50
|
-
"@stencil/core": "5.0.0-alpha.
|
|
50
|
+
"@stencil/core": "5.0.0-alpha.9"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@stencil/core": "^5.0.0-0"
|