pinme 2.0.8-beta.1 → 2.0.9-beta.1
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 +79 -139
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5978,7 +5978,7 @@ var import_chalk26 = __toESM(require("chalk"));
|
|
|
5978
5978
|
var import_figlet5 = __toESM(require("figlet"));
|
|
5979
5979
|
|
|
5980
5980
|
// package.json
|
|
5981
|
-
var version = "2.0.
|
|
5981
|
+
var version = "2.0.9-beta.1";
|
|
5982
5982
|
|
|
5983
5983
|
// bin/upload.ts
|
|
5984
5984
|
var import_path7 = __toESM(require("path"));
|
|
@@ -9067,16 +9067,8 @@ var import_os5 = __toESM(require("os"));
|
|
|
9067
9067
|
var import_path11 = __toESM(require("path"));
|
|
9068
9068
|
var import_chalk19 = __toESM(require("chalk"));
|
|
9069
9069
|
var import_child_process3 = require("child_process");
|
|
9070
|
-
var
|
|
9071
|
-
|
|
9072
|
-
constructor(command, cause) {
|
|
9073
|
-
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
9074
|
-
super(`${command} failed: ${reason}`);
|
|
9075
|
-
this.name = "DependencyInstallError";
|
|
9076
|
-
this.command = command;
|
|
9077
|
-
this.cause = cause;
|
|
9078
|
-
}
|
|
9079
|
-
};
|
|
9070
|
+
var INSTALL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
9071
|
+
var SLOW_INSTALL_NOTICE_MS = 60 * 1e3;
|
|
9080
9072
|
function makeTempCacheDir() {
|
|
9081
9073
|
return import_fs_extra5.default.mkdtempSync(import_path11.default.join(import_os5.default.tmpdir(), "pinme-npm-cache-"));
|
|
9082
9074
|
}
|
|
@@ -9089,54 +9081,57 @@ function getNpmCommand() {
|
|
|
9089
9081
|
function hasPackageLock(cwd) {
|
|
9090
9082
|
return import_fs_extra5.default.existsSync(import_path11.default.join(cwd, "package-lock.json"));
|
|
9091
9083
|
}
|
|
9092
|
-
function getInstallScript(cwd) {
|
|
9084
|
+
function getInstallScript(cwd, mode) {
|
|
9085
|
+
if (mode !== "auto") {
|
|
9086
|
+
return mode;
|
|
9087
|
+
}
|
|
9093
9088
|
return hasPackageLock(cwd) ? "ci" : "install";
|
|
9094
9089
|
}
|
|
9095
|
-
function
|
|
9096
|
-
return
|
|
9097
|
-
|
|
9098
|
-
|
|
9090
|
+
function getInstallArgs(script, cacheDir) {
|
|
9091
|
+
return [
|
|
9092
|
+
script,
|
|
9093
|
+
"--cache",
|
|
9094
|
+
cacheDir,
|
|
9095
|
+
"--no-audit",
|
|
9096
|
+
"--no-fund",
|
|
9097
|
+
"--fetch-retries=3",
|
|
9098
|
+
"--fetch-retry-factor=2",
|
|
9099
|
+
"--fetch-retry-mintimeout=10000",
|
|
9100
|
+
"--fetch-retry-maxtimeout=60000",
|
|
9101
|
+
"--fetch-timeout=60000"
|
|
9102
|
+
];
|
|
9103
|
+
}
|
|
9104
|
+
function startBackgroundInstall(cwd) {
|
|
9099
9105
|
const npm = getNpmCommand();
|
|
9100
|
-
const
|
|
9106
|
+
const script = getInstallScript(cwd, "auto");
|
|
9107
|
+
const cacheDir = makeTempCacheDir();
|
|
9108
|
+
const args = getInstallArgs(script, cacheDir);
|
|
9109
|
+
const logPath = import_path11.default.join(cwd, ".pinme-install.log");
|
|
9110
|
+
const header = `
|
|
9111
|
+
[pinme] ${(/* @__PURE__ */ new Date()).toISOString()} starting "npm ${script}"
|
|
9112
|
+
`;
|
|
9113
|
+
import_fs_extra5.default.writeFileSync(logPath, header);
|
|
9114
|
+
const logFd = import_fs_extra5.default.openSync(logPath, "a");
|
|
9115
|
+
const child = (0, import_child_process3.spawn)(npm, args, {
|
|
9101
9116
|
cwd,
|
|
9102
|
-
|
|
9117
|
+
detached: true,
|
|
9118
|
+
stdio: ["ignore", logFd, logFd],
|
|
9103
9119
|
shell: true,
|
|
9104
9120
|
env: {
|
|
9105
9121
|
...process.env,
|
|
9106
9122
|
npm_config_cache: cacheDir,
|
|
9107
9123
|
npm_config_audit: "false",
|
|
9108
|
-
npm_config_fund: "false"
|
|
9124
|
+
npm_config_fund: "false",
|
|
9125
|
+
npm_config_fetch_retries: "3",
|
|
9126
|
+
npm_config_fetch_retry_factor: "2",
|
|
9127
|
+
npm_config_fetch_retry_mintimeout: "10000",
|
|
9128
|
+
npm_config_fetch_retry_maxtimeout: "60000",
|
|
9129
|
+
npm_config_fetch_timeout: "60000"
|
|
9109
9130
|
}
|
|
9110
9131
|
});
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
}
|
|
9114
|
-
if (result.status !== 0) {
|
|
9115
|
-
throw new Error(`npm ${script} failed with exit code ${result.status}`);
|
|
9116
|
-
}
|
|
9117
|
-
}
|
|
9118
|
-
function installProjectDependencies(cwd) {
|
|
9119
|
-
const script = getInstallScript(cwd);
|
|
9120
|
-
const command = formatInstallCommand(script);
|
|
9121
|
-
let lastError;
|
|
9122
|
-
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
9123
|
-
const cacheDir = makeTempCacheDir();
|
|
9124
|
-
try {
|
|
9125
|
-
if (attempt > 1) {
|
|
9126
|
-
console.log(import_chalk19.default.yellow(" Retrying dependency install with a fresh npm cache..."));
|
|
9127
|
-
}
|
|
9128
|
-
if (attempt === 1 && script === "ci") {
|
|
9129
|
-
console.log(import_chalk19.default.gray(" package-lock.json found; using npm ci for a reproducible install."));
|
|
9130
|
-
}
|
|
9131
|
-
runInstall(cwd, cacheDir, script);
|
|
9132
|
-
return;
|
|
9133
|
-
} catch (error) {
|
|
9134
|
-
lastError = error;
|
|
9135
|
-
} finally {
|
|
9136
|
-
import_fs_extra5.default.removeSync(cacheDir);
|
|
9137
|
-
}
|
|
9138
|
-
}
|
|
9139
|
-
throw new DependencyInstallError(command, lastError);
|
|
9132
|
+
import_fs_extra5.default.closeSync(logFd);
|
|
9133
|
+
child.unref();
|
|
9134
|
+
return { logPath };
|
|
9140
9135
|
}
|
|
9141
9136
|
|
|
9142
9137
|
// bin/create.ts
|
|
@@ -9312,23 +9307,14 @@ Directory "${projectName}" already exists.`));
|
|
|
9312
9307
|
import_fs_extra6.default.removeSync(zipPath);
|
|
9313
9308
|
import_fs_extra6.default.removeSync(extractDir);
|
|
9314
9309
|
const nodeModulesPath = import_path12.default.join(targetDir, "node_modules");
|
|
9315
|
-
const packageLockPath = import_path12.default.join(targetDir, "package-lock.json");
|
|
9316
9310
|
if (import_fs_extra6.default.existsSync(nodeModulesPath)) {
|
|
9317
9311
|
console.log(import_chalk20.default.gray(" Removing existing node_modules..."));
|
|
9318
9312
|
import_fs_extra6.default.removeSync(nodeModulesPath);
|
|
9319
9313
|
}
|
|
9320
|
-
if (import_fs_extra6.default.existsSync(packageLockPath)) {
|
|
9321
|
-
console.log(import_chalk20.default.gray(" Removing existing package-lock.json..."));
|
|
9322
|
-
import_fs_extra6.default.removeSync(packageLockPath);
|
|
9323
|
-
}
|
|
9324
9314
|
const frontendNodeModules = import_path12.default.join(targetDir, "frontend", "node_modules");
|
|
9325
9315
|
const backendNodeModules = import_path12.default.join(targetDir, "backend", "node_modules");
|
|
9326
|
-
const frontendPackageLock = import_path12.default.join(targetDir, "frontend", "package-lock.json");
|
|
9327
|
-
const backendPackageLock = import_path12.default.join(targetDir, "backend", "package-lock.json");
|
|
9328
9316
|
if (import_fs_extra6.default.existsSync(frontendNodeModules)) import_fs_extra6.default.removeSync(frontendNodeModules);
|
|
9329
9317
|
if (import_fs_extra6.default.existsSync(backendNodeModules)) import_fs_extra6.default.removeSync(backendNodeModules);
|
|
9330
|
-
if (import_fs_extra6.default.existsSync(frontendPackageLock)) import_fs_extra6.default.removeSync(frontendPackageLock);
|
|
9331
|
-
if (import_fs_extra6.default.existsSync(backendPackageLock)) import_fs_extra6.default.removeSync(backendPackageLock);
|
|
9332
9318
|
console.log(import_chalk20.default.green(` Template downloaded to: ${targetDir}`));
|
|
9333
9319
|
} catch (error) {
|
|
9334
9320
|
throw createCommandError("template extraction", `extract "${zipPath}" to "${extractDir}"`, error, [
|
|
@@ -9406,53 +9392,22 @@ Directory "${projectName}" already exists.`));
|
|
|
9406
9392
|
}
|
|
9407
9393
|
import_fs_extra6.default.writeFileSync(configPath, pinmeConfig);
|
|
9408
9394
|
console.log(import_chalk20.default.green(` Updated pinme.toml with api_url`));
|
|
9409
|
-
console.log(import_chalk20.default.blue("\n4. Installing dependencies..."));
|
|
9410
|
-
try {
|
|
9411
|
-
installProjectDependencies(targetDir);
|
|
9412
|
-
console.log(import_chalk20.default.green(" Project dependencies installed"));
|
|
9413
|
-
} catch (error) {
|
|
9414
|
-
const errorMsg = error.message || "";
|
|
9415
|
-
const installCommand = error instanceof DependencyInstallError ? error.command : "npm ci/npm install --cache <isolated npm cache> --no-audit --no-fund";
|
|
9416
|
-
if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("permission denied")) {
|
|
9417
|
-
throw createCommandError("project dependency install", installCommand, error, [
|
|
9418
|
-
"Permission error detected. Pinme already retries with an isolated npm cache.",
|
|
9419
|
-
"Check whether the project directory is writable:",
|
|
9420
|
-
" ls -la " + targetDir,
|
|
9421
|
-
"If npm still reports a root-owned cache, set `npm_config_cache` to a user-writable directory and retry."
|
|
9422
|
-
]);
|
|
9423
|
-
}
|
|
9424
|
-
if (errorMsg.includes("ENOTFOUND") || errorMsg.includes("ETIMEDOUT") || errorMsg.includes("network")) {
|
|
9425
|
-
throw createCommandError("project dependency install", installCommand, error, [
|
|
9426
|
-
"Network error detected. Please check:",
|
|
9427
|
-
" 1. Internet connection is available",
|
|
9428
|
-
" 2. npm registry is accessible (https://registry.npmjs.org)",
|
|
9429
|
-
" 3. Try using a mirror: npm config set registry https://registry.npmmirror.com"
|
|
9430
|
-
]);
|
|
9431
|
-
}
|
|
9432
|
-
throw createCommandError("project dependency install", installCommand, error, [
|
|
9433
|
-
"Dependency installation failed.",
|
|
9434
|
-
"Check network connectivity and npm registry availability.",
|
|
9435
|
-
"Inspect the generated workspace `package.json` files for dependency conflicts.",
|
|
9436
|
-
"If `package-lock.json` is stale, update it intentionally with `npm install` before retrying."
|
|
9437
|
-
]);
|
|
9438
|
-
}
|
|
9439
|
-
console.log(import_chalk20.default.blue("\n5. Building backend worker..."));
|
|
9395
|
+
console.log(import_chalk20.default.blue("\n4. Installing dependencies in the background..."));
|
|
9440
9396
|
try {
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
});
|
|
9445
|
-
console.log(import_chalk20.default.green(" Worker built"));
|
|
9397
|
+
const { logPath } = startBackgroundInstall(targetDir);
|
|
9398
|
+
console.log(import_chalk20.default.gray(" Dependencies are installing in the background; create will continue."));
|
|
9399
|
+
console.log(import_chalk20.default.gray(` Install progress is logged to: ${logPath}`));
|
|
9446
9400
|
} catch (error) {
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
]);
|
|
9401
|
+
console.log(import_chalk20.default.yellow(" Warning: could not start background dependency install."));
|
|
9402
|
+
console.log(import_chalk20.default.yellow(" Run `npm install` inside the project before `pinme save`."));
|
|
9450
9403
|
}
|
|
9404
|
+
console.log(import_chalk20.default.blue("\n5. Preparing backend worker..."));
|
|
9451
9405
|
const distWorkerDir = import_path12.default.join(targetDir, "dist-worker");
|
|
9452
9406
|
const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
|
|
9453
9407
|
if (!import_fs_extra6.default.existsSync(distWorkerDir) || !import_fs_extra6.default.existsSync(workerJsPath)) {
|
|
9454
|
-
throw createConfigError("
|
|
9455
|
-
"
|
|
9408
|
+
throw createConfigError("Prebuilt worker output not found: `dist-worker/worker.js`.", [
|
|
9409
|
+
"The template should ship a prebuilt `dist-worker/`.",
|
|
9410
|
+
"Once dependencies finish installing, run `npm run build:worker` in the project, then `pinme save`."
|
|
9456
9411
|
]);
|
|
9457
9412
|
}
|
|
9458
9413
|
const modulePaths = [];
|
|
@@ -9527,23 +9482,19 @@ Directory "${projectName}" already exists.`));
|
|
|
9527
9482
|
"Check whether backend metadata, SQL files, or worker bundle contains invalid content."
|
|
9528
9483
|
]);
|
|
9529
9484
|
}
|
|
9530
|
-
console.log(import_chalk20.default.blue("\n7.
|
|
9485
|
+
console.log(import_chalk20.default.blue("\n7. Preparing frontend..."));
|
|
9531
9486
|
const frontendDir = import_path12.default.join(targetDir, "frontend");
|
|
9487
|
+
const frontendDistDir = import_path12.default.join(frontendDir, "dist");
|
|
9532
9488
|
if (import_fs_extra6.default.existsSync(frontendDir)) {
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
});
|
|
9538
|
-
console.log(import_chalk20.default.green(" Frontend built"));
|
|
9539
|
-
} catch (error) {
|
|
9540
|
-
throw createCommandError("frontend build", "npm run build:frontend", error, [
|
|
9541
|
-
"Fix the frontend build error shown above, then rerun `pinme create`."
|
|
9489
|
+
if (!import_fs_extra6.default.existsSync(frontendDistDir)) {
|
|
9490
|
+
throw createConfigError("Prebuilt frontend output not found: `frontend/dist/`.", [
|
|
9491
|
+
"The template should ship a prebuilt `frontend/dist/`.",
|
|
9492
|
+
"Once dependencies finish installing, run `npm run build:frontend` in the project, then `pinme save`."
|
|
9542
9493
|
]);
|
|
9543
9494
|
}
|
|
9544
9495
|
console.log(import_chalk20.default.blue(" Uploading to IPFS..."));
|
|
9545
9496
|
try {
|
|
9546
|
-
const uploadResult = await uploadPath(
|
|
9497
|
+
const uploadResult = await uploadPath(frontendDistDir, {
|
|
9547
9498
|
action: "project_create",
|
|
9548
9499
|
projectName: workerData.project_name,
|
|
9549
9500
|
uid: headers["token-address"]
|
|
@@ -9651,36 +9602,25 @@ function buildWorker() {
|
|
|
9651
9602
|
]);
|
|
9652
9603
|
}
|
|
9653
9604
|
}
|
|
9654
|
-
function
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
console.log(import_chalk21.default.
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
]);
|
|
9669
|
-
}
|
|
9670
|
-
if (errorMsg.includes("ENOTFOUND") || errorMsg.includes("ETIMEDOUT") || errorMsg.includes("network")) {
|
|
9671
|
-
throw createCommandError("project dependency install", installCommand, error, [
|
|
9672
|
-
"Network error detected. Please check:",
|
|
9673
|
-
" 1. Internet connection is available",
|
|
9674
|
-
" 2. npm registry is accessible (https://registry.npmjs.org)",
|
|
9675
|
-
" 3. Try using a mirror: npm config set registry https://registry.npmmirror.com"
|
|
9676
|
-
]);
|
|
9677
|
-
}
|
|
9678
|
-
throw createCommandError("project dependency install", installCommand, error, [
|
|
9679
|
-
"Dependency installation failed.",
|
|
9680
|
-
"Check network connectivity and npm registry availability.",
|
|
9681
|
-
"If `package-lock.json` is stale, update it intentionally with `npm install` before retrying."
|
|
9682
|
-
]);
|
|
9605
|
+
function ensureDependenciesInstalled() {
|
|
9606
|
+
const nodeModulesPath = import_path13.default.join(PROJECT_DIR2, "node_modules");
|
|
9607
|
+
const installLogPath = import_path13.default.join(PROJECT_DIR2, ".pinme-install.log");
|
|
9608
|
+
if (import_fs_extra7.default.existsSync(nodeModulesPath)) {
|
|
9609
|
+
console.log(import_chalk21.default.gray("Dependencies already installed; skipping install."));
|
|
9610
|
+
return;
|
|
9611
|
+
}
|
|
9612
|
+
const suggestions = [
|
|
9613
|
+
"Dependencies are not installed. Run `npm install` in the project root, wait for it to finish, then rerun `pinme save`."
|
|
9614
|
+
];
|
|
9615
|
+
if (import_fs_extra7.default.existsSync(installLogPath)) {
|
|
9616
|
+
suggestions.push(
|
|
9617
|
+
`A background install may still be running (started by \`pinme create\`). Check progress in \`${installLogPath}\` before retrying.`
|
|
9618
|
+
);
|
|
9683
9619
|
}
|
|
9620
|
+
throw createConfigError(
|
|
9621
|
+
"Project dependencies are not installed: `node_modules` is missing.",
|
|
9622
|
+
suggestions
|
|
9623
|
+
);
|
|
9684
9624
|
}
|
|
9685
9625
|
function getBuiltWorker() {
|
|
9686
9626
|
const distWorkerDir = import_path13.default.join(PROJECT_DIR2, "dist-worker");
|
|
@@ -9886,7 +9826,7 @@ async function saveCmd(options) {
|
|
|
9886
9826
|
const apiUrl = `${getPinmeApiUrl("/save_worker")}?project_name=${encodeURIComponent(projectName)}`;
|
|
9887
9827
|
console.log(import_chalk21.default.gray(`API URL: ${apiUrl}`));
|
|
9888
9828
|
console.log(import_chalk21.default.blue("\n--- Backend ---"));
|
|
9889
|
-
|
|
9829
|
+
ensureDependenciesInstalled();
|
|
9890
9830
|
buildWorker();
|
|
9891
9831
|
const metadata = getMetadata();
|
|
9892
9832
|
const { workerJsPath, modulePaths } = getBuiltWorker();
|