@stencil/cli 5.0.0-alpha.25 → 5.0.0-alpha.27
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.mjs +61 -9
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { addDevDependency, detectPackageManager, installDependencies } from "nyp
|
|
|
9
9
|
import { isCI } from "std-env";
|
|
10
10
|
import ts from "typescript";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { getPackageInfo } from "local-pkg";
|
|
12
13
|
import { existsSync } from "node:fs";
|
|
13
14
|
import { homedir } from "node:os";
|
|
14
15
|
import { dirname as dirname$1, isAbsolute, join as join$1, relative as relative$1 } from "path";
|
|
@@ -768,9 +769,11 @@ async function readJson$1(filePath) {
|
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
771
|
async function loadOne(rootDir, packageName, loader) {
|
|
771
|
-
const
|
|
772
|
+
const info = await getPackageInfo(packageName, { paths: [rootDir] });
|
|
773
|
+
if (!info) return null;
|
|
774
|
+
const wizardEntry = info.packageJson.stencil?.wizard;
|
|
772
775
|
if (!wizardEntry) return null;
|
|
773
|
-
const wizardPath = join(
|
|
776
|
+
const wizardPath = join(info.rootPath, wizardEntry);
|
|
774
777
|
let mod;
|
|
775
778
|
try {
|
|
776
779
|
mod = await loader(pathToFileURL(wizardPath).href);
|
|
@@ -1194,7 +1197,7 @@ async function isExistingStencilProject(dir) {
|
|
|
1194
1197
|
}
|
|
1195
1198
|
//#endregion
|
|
1196
1199
|
//#region src/wizard/splash.ts
|
|
1197
|
-
const CLI_VERSION = "5.0.0-alpha.
|
|
1200
|
+
const CLI_VERSION = "5.0.0-alpha.27";
|
|
1198
1201
|
const isTTY = process.stdout.isTTY;
|
|
1199
1202
|
const noColor = !isTTY || "NO_COLOR" in process.env;
|
|
1200
1203
|
const RESET = noColor ? "" : "\x1B[0m";
|
|
@@ -4016,6 +4019,49 @@ async function applyPackageJsonFields(rootDir, fields) {
|
|
|
4016
4019
|
}
|
|
4017
4020
|
//#endregion
|
|
4018
4021
|
//#region src/task-init.ts
|
|
4022
|
+
/**
|
|
4023
|
+
* Package managers can report success while silently failing to write to node_modules
|
|
4024
|
+
* (observed with npm computing a resolved lockfile but reifying zero filesystem changes).
|
|
4025
|
+
* Confirms packages actually landed on disk instead of trusting the install call's exit code.
|
|
4026
|
+
*
|
|
4027
|
+
* @param rootDir - directory to resolve packages from.
|
|
4028
|
+
* @param packageNames - packages that were just supposed to be installed.
|
|
4029
|
+
* @returns names that failed to resolve; empty when everything installed correctly.
|
|
4030
|
+
*/
|
|
4031
|
+
async function verifyInstalled(rootDir, packageNames) {
|
|
4032
|
+
const missing = [];
|
|
4033
|
+
for (const name of packageNames) if (!await getPackageInfo(name, { paths: [rootDir] })) missing.push(name);
|
|
4034
|
+
return missing;
|
|
4035
|
+
}
|
|
4036
|
+
function failInstallVerification(missing, rootDir) {
|
|
4037
|
+
p.log.error(`Install reported success but ${missing.join(", ")} could not be found in ${rootDir}. Your package manager may have silently failed to write to node_modules - check its logs and try again.`);
|
|
4038
|
+
process.exit(1);
|
|
4039
|
+
}
|
|
4040
|
+
const NPM_CONFIG_ENV_PATTERN = /^npm_config_/i;
|
|
4041
|
+
/**
|
|
4042
|
+
* `stencil init` is commonly run via `npx create-stencil` / `npm init stencil`, which means
|
|
4043
|
+
* this process itself is a nested child of an active npm/npx invocation. npm sets `npm_config_*`
|
|
4044
|
+
* env vars on every process it spawns, and a nested `npm install` inherits and gets confused by
|
|
4045
|
+
* the *outer* invocation's config (observed: silently reifying zero changes despite an empty
|
|
4046
|
+
* node_modules - see docs.npmjs.com/cli/using-npm/config and nestjs/nest-cli#153 for the same
|
|
4047
|
+
* class of bug). Stripping them for the duration of our own install calls forces the nested
|
|
4048
|
+
* npm to compute its config fresh from cwd instead of inheriting the outer process's state.
|
|
4049
|
+
*
|
|
4050
|
+
* @param fn - install call to run with a clean environment.
|
|
4051
|
+
* @returns whatever `fn` resolves to.
|
|
4052
|
+
*/
|
|
4053
|
+
async function withoutInheritedNpmConfig(fn) {
|
|
4054
|
+
const saved = {};
|
|
4055
|
+
for (const key of Object.keys(process.env)) if (NPM_CONFIG_ENV_PATTERN.test(key)) {
|
|
4056
|
+
saved[key] = process.env[key];
|
|
4057
|
+
delete process.env[key];
|
|
4058
|
+
}
|
|
4059
|
+
try {
|
|
4060
|
+
return await fn();
|
|
4061
|
+
} finally {
|
|
4062
|
+
for (const [key, value] of Object.entries(saved)) process.env[key] = value;
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4019
4065
|
function outputKeysToTargets(keys) {
|
|
4020
4066
|
const map = {
|
|
4021
4067
|
loader: "loader-bundle",
|
|
@@ -4087,20 +4133,24 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
4087
4133
|
s1.stop("Project files created");
|
|
4088
4134
|
const s2 = p.spinner();
|
|
4089
4135
|
s2.start("Installing dependencies");
|
|
4090
|
-
await installDependencies({
|
|
4136
|
+
await withoutInheritedNpmConfig(() => installDependencies({
|
|
4091
4137
|
cwd,
|
|
4092
4138
|
silent: true
|
|
4093
|
-
});
|
|
4139
|
+
}));
|
|
4094
4140
|
s2.stop("Dependencies installed");
|
|
4141
|
+
const missingBase = await verifyInstalled(coreDir, ["@stencil/core"]);
|
|
4142
|
+
if (missingBase.length > 0) failInstallVerification(missingBase, coreDir);
|
|
4095
4143
|
if (selectedIntegrations.length > 0) {
|
|
4096
4144
|
const s3 = p.spinner();
|
|
4097
4145
|
const pkgs = selectedIntegrations.map((i) => i.package);
|
|
4098
4146
|
s3.start(`Installing ${pkgs.join(", ")}`);
|
|
4099
|
-
await addDevDependency(withVersionRanges(pkgs), {
|
|
4147
|
+
await withoutInheritedNpmConfig(() => addDevDependency(withVersionRanges(pkgs), {
|
|
4100
4148
|
cwd: coreDir,
|
|
4101
4149
|
silent: true
|
|
4102
|
-
});
|
|
4150
|
+
}));
|
|
4103
4151
|
s3.stop("Integrations installed");
|
|
4152
|
+
const missingIntegrations = await verifyInstalled(coreDir, pkgs);
|
|
4153
|
+
if (missingIntegrations.length > 0) failInstallVerification(missingIntegrations, coreDir);
|
|
4104
4154
|
}
|
|
4105
4155
|
if (selectedIntegrations.length > 0) {
|
|
4106
4156
|
const discovered = await discoverPlugins(coreDir);
|
|
@@ -4160,11 +4210,13 @@ async function addCapabilities(cwd, strictConfig) {
|
|
|
4160
4210
|
const s = p.spinner();
|
|
4161
4211
|
const pkgs = toInstall.map((i) => i.package);
|
|
4162
4212
|
s.start(`Installing ${pkgs.join(", ")}`);
|
|
4163
|
-
await addDevDependency(withVersionRanges(pkgs), {
|
|
4213
|
+
await withoutInheritedNpmConfig(() => addDevDependency(withVersionRanges(pkgs), {
|
|
4164
4214
|
cwd,
|
|
4165
4215
|
silent: true
|
|
4166
|
-
});
|
|
4216
|
+
}));
|
|
4167
4217
|
s.stop("Dependencies installed");
|
|
4218
|
+
const missing = await verifyInstalled(cwd, pkgs);
|
|
4219
|
+
if (missing.length > 0) failInstallVerification(missing, cwd);
|
|
4168
4220
|
}
|
|
4169
4221
|
const allDiscovered = toInstall.length > 0 ? await discoverPlugins(cwd) : discovered;
|
|
4170
4222
|
const newlyInstalledPkgs = new Set(toInstall.map((i) => i.package));
|
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.27",
|
|
4
4
|
"description": "CLI for Stencil - Web component compiler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -38,19 +38,20 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@clack/prompts": "^1.5.1",
|
|
41
|
+
"local-pkg": "^1.2.1",
|
|
41
42
|
"nypm": "^0.3.12",
|
|
42
43
|
"std-env": "^3.8.0",
|
|
43
44
|
"typescript": ">4.0.0 <7.0.0",
|
|
44
|
-
"@stencil/
|
|
45
|
-
"@stencil/
|
|
45
|
+
"@stencil/templates": "5.0.0-alpha.27",
|
|
46
|
+
"@stencil/dev-server": "5.0.0-alpha.27"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"tsdown": ">=0.21.0 <1.0.0",
|
|
49
50
|
"vitest": "^4.1.7",
|
|
50
|
-
"@stencil/core": "5.0.0-alpha.
|
|
51
|
+
"@stencil/core": "5.0.0-alpha.27"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
|
-
"@stencil/core": "^5.0.0 || 5.0.0-alpha.
|
|
54
|
+
"@stencil/core": "^5.0.0 || 5.0.0-alpha.27"
|
|
54
55
|
},
|
|
55
56
|
"volta": {
|
|
56
57
|
"extends": "../../package.json"
|