@metasession.co/devaudit-cli 0.3.2 → 0.3.3
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.js +31 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/sdlc/files/_common/0-project-setup.md +11 -0
- package/sdlc/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function emitJsonResult(payload) {
|
|
|
56
56
|
|
|
57
57
|
// package.json
|
|
58
58
|
var package_default = {
|
|
59
|
-
version: "0.3.
|
|
59
|
+
version: "0.3.3"};
|
|
60
60
|
|
|
61
61
|
// src/lib/version.ts
|
|
62
62
|
var CLI_VERSION = package_default.version;
|
|
@@ -2015,6 +2015,8 @@ async function syncStackHooks(ctx) {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
return { name: `${ctx.stack} hooks`, filesSynced: count, message: `synced to ${hookInstallDir}/` };
|
|
2017
2017
|
}
|
|
2018
|
+
var PLAYWRIGHT_POSTINSTALL = "playwright install chromium";
|
|
2019
|
+
var PLAYWRIGHT_DEP = "@playwright/test";
|
|
2018
2020
|
async function syncStackDeps(ctx) {
|
|
2019
2021
|
if (ctx.stack !== "node") {
|
|
2020
2022
|
return { name: `${ctx.stack} deps`, filesSynced: 0, skipped: true };
|
|
@@ -2033,26 +2035,51 @@ async function syncStackDeps(ctx) {
|
|
|
2033
2035
|
const installed = new Set(Object.keys(pkg.devDependencies ?? {}));
|
|
2034
2036
|
const missing = required.filter((dep) => !installed.has(dep));
|
|
2035
2037
|
if (missing.length === 0) {
|
|
2036
|
-
|
|
2038
|
+
const added = await ensurePostinstallScript(pkgPath, required);
|
|
2039
|
+
return { name: `${ctx.stack} deps`, filesSynced: 0, message: added ? "all present, added postinstall" : "all present" };
|
|
2037
2040
|
}
|
|
2038
2041
|
const args = ["install", "--save-dev", ...missing];
|
|
2039
2042
|
const first = await execa("npm", args, { cwd: ctx.projectPath, reject: false, stdio: "inherit" });
|
|
2040
2043
|
if (first.exitCode === 0) {
|
|
2041
|
-
|
|
2044
|
+
const added = await ensurePostinstallScript(pkgPath, required);
|
|
2045
|
+
return { name: `${ctx.stack} deps`, filesSynced: missing.length, message: `installed ${missing.join(" ")}${added ? ", added postinstall" : ""}` };
|
|
2042
2046
|
}
|
|
2043
2047
|
const legacyArgs = ["install", "--save-dev", "--legacy-peer-deps", ...missing];
|
|
2044
2048
|
const second = await execa("npm", legacyArgs, { cwd: ctx.projectPath, reject: false, stdio: "inherit" });
|
|
2045
2049
|
if (second.exitCode === 0) {
|
|
2050
|
+
const added = await ensurePostinstallScript(pkgPath, required);
|
|
2046
2051
|
return {
|
|
2047
2052
|
name: `${ctx.stack} deps`,
|
|
2048
2053
|
filesSynced: missing.length,
|
|
2049
|
-
message: `installed ${missing.join(" ")} (with --legacy-peer-deps)`
|
|
2054
|
+
message: `installed ${missing.join(" ")} (with --legacy-peer-deps)${added ? ", added postinstall" : ""}`
|
|
2050
2055
|
};
|
|
2051
2056
|
}
|
|
2052
2057
|
throw new Error(
|
|
2053
2058
|
`Failed to install ${ctx.stack} deps. Fix manually: cd ${ctx.projectPath} && npm install --save-dev ${missing.join(" ")}`
|
|
2054
2059
|
);
|
|
2055
2060
|
}
|
|
2061
|
+
async function ensurePostinstallScript(pkgPath, requiredDeps) {
|
|
2062
|
+
if (!requiredDeps.includes(PLAYWRIGHT_DEP)) {
|
|
2063
|
+
return false;
|
|
2064
|
+
}
|
|
2065
|
+
const raw = await promises.readFile(pkgPath, "utf-8");
|
|
2066
|
+
const pkg = JSON.parse(raw);
|
|
2067
|
+
const scripts = pkg.scripts ?? {};
|
|
2068
|
+
const existing = scripts["postinstall"];
|
|
2069
|
+
if (existing === PLAYWRIGHT_POSTINSTALL) {
|
|
2070
|
+
return false;
|
|
2071
|
+
}
|
|
2072
|
+
if (existing && !existing.includes("playwright install")) {
|
|
2073
|
+
logger().warn(
|
|
2074
|
+
` postinstall script already exists ("${existing}") \u2014 not overwriting. Add "playwright install chromium" manually if needed.`
|
|
2075
|
+
);
|
|
2076
|
+
return false;
|
|
2077
|
+
}
|
|
2078
|
+
scripts["postinstall"] = PLAYWRIGHT_POSTINSTALL;
|
|
2079
|
+
pkg.scripts = scripts;
|
|
2080
|
+
await promises.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
2081
|
+
return true;
|
|
2082
|
+
}
|
|
2056
2083
|
function isTestScript(name) {
|
|
2057
2084
|
return name.endsWith(".test.sh");
|
|
2058
2085
|
}
|