@uniformdev/cli 19.63.0 → 19.63.2
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 +167 -46
- package/package.json +9 -8
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
2
9
|
|
|
3
10
|
// ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_ts-node@10.9.1_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
|
|
4
11
|
import { fileURLToPath } from "url";
|
|
@@ -5068,7 +5075,7 @@ import { PostHog } from "posthog-node";
|
|
|
5068
5075
|
// package.json
|
|
5069
5076
|
var package_default = {
|
|
5070
5077
|
name: "@uniformdev/cli",
|
|
5071
|
-
version: "19.63.
|
|
5078
|
+
version: "19.63.2",
|
|
5072
5079
|
description: "Uniform command line interface tool",
|
|
5073
5080
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
5074
5081
|
main: "./cli.js",
|
|
@@ -5112,8 +5119,9 @@ var package_default = {
|
|
|
5112
5119
|
ora: "7.0.1",
|
|
5113
5120
|
"p-queue": "7.3.4",
|
|
5114
5121
|
"posthog-node": "3.1.2",
|
|
5122
|
+
"registry-auth-token": "^5.0.0",
|
|
5123
|
+
"registry-url": "^6.0.0",
|
|
5115
5124
|
slugify: "1.6.6",
|
|
5116
|
-
"update-check": "^1.5.4",
|
|
5117
5125
|
yargs: "^17.6.2",
|
|
5118
5126
|
zod: "3.22.3"
|
|
5119
5127
|
},
|
|
@@ -5787,24 +5795,6 @@ async function newHandler({
|
|
|
5787
5795
|
previewPath: "/api/preview?secret=hello-world",
|
|
5788
5796
|
installEnv: []
|
|
5789
5797
|
}
|
|
5790
|
-
},
|
|
5791
|
-
javadrip: {
|
|
5792
|
-
name: "Commerce Starter",
|
|
5793
|
-
value: {
|
|
5794
|
-
githubUri: "uniformdev/commerce-starter",
|
|
5795
|
-
serverUrl: "http://localhost:3000",
|
|
5796
|
-
previewPath: "/api/preview?secret=javadrip",
|
|
5797
|
-
installEnv: []
|
|
5798
|
-
}
|
|
5799
|
-
},
|
|
5800
|
-
uniformconf: {
|
|
5801
|
-
name: "Marketing Site Starter",
|
|
5802
|
-
value: {
|
|
5803
|
-
githubUri: "uniformdev/uniformconf",
|
|
5804
|
-
serverUrl: "http://localhost:3000",
|
|
5805
|
-
previewPath: "/api/preview?secret=uniformconf",
|
|
5806
|
-
installEnv: []
|
|
5807
|
-
}
|
|
5808
5798
|
}
|
|
5809
5799
|
},
|
|
5810
5800
|
nuxt: {
|
|
@@ -5816,15 +5806,6 @@ async function newHandler({
|
|
|
5816
5806
|
previewPath: "/?preview=true",
|
|
5817
5807
|
installEnv: [["NUXT_TELEMETRY_DISABLED", "1"]]
|
|
5818
5808
|
}
|
|
5819
|
-
},
|
|
5820
|
-
uniformconf: {
|
|
5821
|
-
name: "Marketing Site Starter",
|
|
5822
|
-
value: {
|
|
5823
|
-
githubUri: "uniformdev/uniformconf-nuxt",
|
|
5824
|
-
serverUrl: "http://localhost:3000",
|
|
5825
|
-
previewPath: "/?preview=true",
|
|
5826
|
-
installEnv: [["NUXT_TELEMETRY_DISABLED", "1"]]
|
|
5827
|
-
}
|
|
5828
5809
|
}
|
|
5829
5810
|
}
|
|
5830
5811
|
};
|
|
@@ -5867,16 +5848,6 @@ async function newHandler({
|
|
|
5867
5848
|
] : []
|
|
5868
5849
|
).map(([name, value]) => `${name}='${value}'`).join("\n") + "\n";
|
|
5869
5850
|
await done();
|
|
5870
|
-
if (githubUri.endsWith("commerce-starter")) {
|
|
5871
|
-
const stableFakecommerceId = "fakecommerce-d04dcf12-f811-401d-add8-1fb81cfdb8a5";
|
|
5872
|
-
const canaryFakecommerceId = "fakecommerce-f94cf199-7ea4-46ce-ae8b-825668bb79bc";
|
|
5873
|
-
done = await spin2("Installing Fake Commerce...");
|
|
5874
|
-
await uniformClient.installIntegration({
|
|
5875
|
-
projectId,
|
|
5876
|
-
type: apiHost.includes("canary") ? canaryFakecommerceId : stableFakecommerceId
|
|
5877
|
-
});
|
|
5878
|
-
await done();
|
|
5879
|
-
}
|
|
5880
5851
|
const cloneStartTimestamp = Date.now();
|
|
5881
5852
|
const { runNpmInstall } = await cloneStarter({
|
|
5882
5853
|
githubPath: githubUri,
|
|
@@ -7402,7 +7373,6 @@ var SyncCommand = {
|
|
|
7402
7373
|
|
|
7403
7374
|
// src/middleware/checkForUpdateMiddleware.ts
|
|
7404
7375
|
import { bold, gray as gray5, green as green4 } from "colorette";
|
|
7405
|
-
import updateCheck from "update-check";
|
|
7406
7376
|
|
|
7407
7377
|
// src/log.ts
|
|
7408
7378
|
import { reset } from "colorette";
|
|
@@ -7423,13 +7393,164 @@ function logCallout(options) {
|
|
|
7423
7393
|
console.log("");
|
|
7424
7394
|
}
|
|
7425
7395
|
|
|
7396
|
+
// src/updateCheck.ts
|
|
7397
|
+
import { existsSync as existsSync4, promises as fs5 } from "fs";
|
|
7398
|
+
import { get as getHttp } from "http";
|
|
7399
|
+
import { get as getHttps } from "https";
|
|
7400
|
+
import { tmpdir } from "os";
|
|
7401
|
+
import { join as join3 } from "path";
|
|
7402
|
+
import registryUrl from "registry-url";
|
|
7403
|
+
import { URL as URL2 } from "url";
|
|
7404
|
+
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
7405
|
+
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
7406
|
+
var getFile = async (details, distTag) => {
|
|
7407
|
+
const rootDir = tmpdir();
|
|
7408
|
+
const subDir = join3(rootDir, "update-check");
|
|
7409
|
+
if (!existsSync4(subDir)) {
|
|
7410
|
+
await fs5.mkdir(subDir);
|
|
7411
|
+
}
|
|
7412
|
+
let name = `${details.name}-${distTag}.json`;
|
|
7413
|
+
if (details.scope) {
|
|
7414
|
+
name = `${details.scope}-${name}`;
|
|
7415
|
+
}
|
|
7416
|
+
return join3(subDir, name);
|
|
7417
|
+
};
|
|
7418
|
+
var evaluateCache = async (file, time, interval) => {
|
|
7419
|
+
if (existsSync4(file)) {
|
|
7420
|
+
const content = await fs5.readFile(file, "utf8");
|
|
7421
|
+
const { lastUpdate, latest } = JSON.parse(content);
|
|
7422
|
+
const nextCheck = lastUpdate + interval;
|
|
7423
|
+
if (nextCheck > time) {
|
|
7424
|
+
return {
|
|
7425
|
+
shouldCheck: false,
|
|
7426
|
+
latest
|
|
7427
|
+
};
|
|
7428
|
+
}
|
|
7429
|
+
}
|
|
7430
|
+
return {
|
|
7431
|
+
shouldCheck: true,
|
|
7432
|
+
latest: null
|
|
7433
|
+
};
|
|
7434
|
+
};
|
|
7435
|
+
var updateCache = async (file, latest, lastUpdate) => {
|
|
7436
|
+
const content = JSON.stringify({
|
|
7437
|
+
latest,
|
|
7438
|
+
lastUpdate
|
|
7439
|
+
});
|
|
7440
|
+
await fs5.writeFile(file, content, "utf8");
|
|
7441
|
+
};
|
|
7442
|
+
var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve2, reject) => {
|
|
7443
|
+
const options = {
|
|
7444
|
+
host: url.hostname,
|
|
7445
|
+
path: url.pathname,
|
|
7446
|
+
port: url.port,
|
|
7447
|
+
headers: {
|
|
7448
|
+
accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
7449
|
+
},
|
|
7450
|
+
timeout
|
|
7451
|
+
};
|
|
7452
|
+
if (authInfo) {
|
|
7453
|
+
options.headers.authorization = `${authInfo.type} ${authInfo.token}`;
|
|
7454
|
+
}
|
|
7455
|
+
const get = url.protocol === "https:" ? getHttps : getHttp;
|
|
7456
|
+
get(options, (response) => {
|
|
7457
|
+
const { statusCode } = response;
|
|
7458
|
+
if (statusCode !== 200) {
|
|
7459
|
+
const error = new Error(`Request failed with code ${statusCode}`);
|
|
7460
|
+
error.code = statusCode;
|
|
7461
|
+
reject(error);
|
|
7462
|
+
response.resume();
|
|
7463
|
+
return;
|
|
7464
|
+
}
|
|
7465
|
+
let rawData = "";
|
|
7466
|
+
response.setEncoding("utf8");
|
|
7467
|
+
response.on("data", (chunk) => {
|
|
7468
|
+
rawData += chunk;
|
|
7469
|
+
});
|
|
7470
|
+
response.on("end", () => {
|
|
7471
|
+
try {
|
|
7472
|
+
const parsedData = JSON.parse(rawData);
|
|
7473
|
+
resolve2(parsedData);
|
|
7474
|
+
} catch (e) {
|
|
7475
|
+
reject(e);
|
|
7476
|
+
}
|
|
7477
|
+
});
|
|
7478
|
+
}).on("error", reject).on("timeout", () => reject(new Error("Request timeout")));
|
|
7479
|
+
});
|
|
7480
|
+
var getMostRecent = async ({ full, scope }, distTag, timeout) => {
|
|
7481
|
+
const regURL = registryUrl(scope ?? "");
|
|
7482
|
+
const url = new URL2(full, regURL);
|
|
7483
|
+
let spec = null;
|
|
7484
|
+
try {
|
|
7485
|
+
spec = await loadPackage({ url, timeout });
|
|
7486
|
+
} catch (err) {
|
|
7487
|
+
if ((err == null ? void 0 : err.code) && String(err.code).startsWith("4")) {
|
|
7488
|
+
const registryAuthToken = __require("registry-auth-token");
|
|
7489
|
+
const authInfo = registryAuthToken(regURL, { recursive: true });
|
|
7490
|
+
spec = await loadPackage({ url, timeout }, authInfo);
|
|
7491
|
+
} else {
|
|
7492
|
+
throw err;
|
|
7493
|
+
}
|
|
7494
|
+
}
|
|
7495
|
+
const version = spec["dist-tags"][distTag];
|
|
7496
|
+
if (!version) {
|
|
7497
|
+
throw new Error(`Distribution tag ${distTag} is not available`);
|
|
7498
|
+
}
|
|
7499
|
+
return version;
|
|
7500
|
+
};
|
|
7501
|
+
var defaultConfig = {
|
|
7502
|
+
interval: 36e5,
|
|
7503
|
+
distTag: "latest",
|
|
7504
|
+
timeout: 2e3
|
|
7505
|
+
};
|
|
7506
|
+
var getDetails = (name) => {
|
|
7507
|
+
const spec = {
|
|
7508
|
+
full: encode(name),
|
|
7509
|
+
name: "",
|
|
7510
|
+
scope: null
|
|
7511
|
+
};
|
|
7512
|
+
if (name.includes("/")) {
|
|
7513
|
+
const parts = name.split("/");
|
|
7514
|
+
spec.scope = parts[0];
|
|
7515
|
+
spec.name = parts[1];
|
|
7516
|
+
} else {
|
|
7517
|
+
spec.scope = null;
|
|
7518
|
+
spec.name = name;
|
|
7519
|
+
}
|
|
7520
|
+
return spec;
|
|
7521
|
+
};
|
|
7522
|
+
async function updateCheck_default(pkg, config2 = {}) {
|
|
7523
|
+
if (typeof pkg !== "object") {
|
|
7524
|
+
throw new Error("The first parameter should be your package.json file content");
|
|
7525
|
+
}
|
|
7526
|
+
const details = getDetails(pkg.name);
|
|
7527
|
+
const time = Date.now();
|
|
7528
|
+
const { distTag, interval, timeout } = Object.assign({}, defaultConfig, config2);
|
|
7529
|
+
const file = await getFile(details, distTag);
|
|
7530
|
+
let latest = null;
|
|
7531
|
+
let shouldCheck = true;
|
|
7532
|
+
({ shouldCheck, latest } = await evaluateCache(file, time, interval));
|
|
7533
|
+
if (shouldCheck) {
|
|
7534
|
+
latest = await getMostRecent(details, distTag, timeout);
|
|
7535
|
+
await updateCache(file, latest, time);
|
|
7536
|
+
}
|
|
7537
|
+
const comparision = compareVersions(pkg.version, latest);
|
|
7538
|
+
if (comparision === -1) {
|
|
7539
|
+
return {
|
|
7540
|
+
latest,
|
|
7541
|
+
fromCache: !shouldCheck
|
|
7542
|
+
};
|
|
7543
|
+
}
|
|
7544
|
+
return null;
|
|
7545
|
+
}
|
|
7546
|
+
|
|
7426
7547
|
// src/middleware/checkForUpdateMiddleware.ts
|
|
7427
7548
|
async function checkForUpdateMiddleware() {
|
|
7428
7549
|
try {
|
|
7429
7550
|
if (process.env.NO_UPDATE_CHECK || process.env.CI) {
|
|
7430
7551
|
return;
|
|
7431
7552
|
}
|
|
7432
|
-
const update = await
|
|
7553
|
+
const update = await updateCheck_default(package_default);
|
|
7433
7554
|
if (update) {
|
|
7434
7555
|
logCallout(`${bold("Update Available:")} ${gray5(package_default.version)} \u226B ${green4(update.latest)}`);
|
|
7435
7556
|
}
|
|
@@ -7440,17 +7561,17 @@ async function checkForUpdateMiddleware() {
|
|
|
7440
7561
|
|
|
7441
7562
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
7442
7563
|
import { magenta, red as red6 } from "colorette";
|
|
7443
|
-
import { join as
|
|
7564
|
+
import { join as join4 } from "path";
|
|
7444
7565
|
|
|
7445
7566
|
// src/fs.ts
|
|
7446
|
-
import { promises as
|
|
7567
|
+
import { promises as fs6 } from "fs";
|
|
7447
7568
|
async function readJSON(path5) {
|
|
7448
|
-
const fileContents = await
|
|
7569
|
+
const fileContents = await fs6.readFile(path5, "utf-8");
|
|
7449
7570
|
return JSON.parse(fileContents);
|
|
7450
7571
|
}
|
|
7451
7572
|
async function tryReadJSON(path5, missingValue = null) {
|
|
7452
7573
|
try {
|
|
7453
|
-
const stat = await
|
|
7574
|
+
const stat = await fs6.stat(path5);
|
|
7454
7575
|
return stat.isFile() ? await readJSON(path5) : missingValue;
|
|
7455
7576
|
} catch (e) {
|
|
7456
7577
|
return missingValue;
|
|
@@ -7479,7 +7600,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
7479
7600
|
try {
|
|
7480
7601
|
let isOutside = false;
|
|
7481
7602
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
7482
|
-
const localPackages = await tryReadJSON(
|
|
7603
|
+
const localPackages = await tryReadJSON(join4(process.cwd(), "package.json"));
|
|
7483
7604
|
if (!localPackages)
|
|
7484
7605
|
return;
|
|
7485
7606
|
let firstVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.63.
|
|
3
|
+
"version": "19.63.2",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@thi.ng/mime": "^2.2.23",
|
|
20
|
-
"@uniformdev/canvas": "19.63.
|
|
21
|
-
"@uniformdev/context": "19.63.
|
|
22
|
-
"@uniformdev/files": "19.63.
|
|
23
|
-
"@uniformdev/project-map": "19.63.
|
|
24
|
-
"@uniformdev/redirect": "19.63.
|
|
20
|
+
"@uniformdev/canvas": "19.63.2",
|
|
21
|
+
"@uniformdev/context": "19.63.2",
|
|
22
|
+
"@uniformdev/files": "19.63.2",
|
|
23
|
+
"@uniformdev/project-map": "19.63.2",
|
|
24
|
+
"@uniformdev/redirect": "19.63.2",
|
|
25
25
|
"call-bind": "^1.0.2",
|
|
26
26
|
"colorette": "2.0.20",
|
|
27
27
|
"cosmiconfig": "8.3.6",
|
|
@@ -44,8 +44,9 @@
|
|
|
44
44
|
"ora": "7.0.1",
|
|
45
45
|
"p-queue": "7.3.4",
|
|
46
46
|
"posthog-node": "3.1.2",
|
|
47
|
+
"registry-auth-token": "^5.0.0",
|
|
48
|
+
"registry-url": "^6.0.0",
|
|
47
49
|
"slugify": "1.6.6",
|
|
48
|
-
"update-check": "^1.5.4",
|
|
49
50
|
"yargs": "^17.6.2",
|
|
50
51
|
"zod": "3.22.3"
|
|
51
52
|
},
|
|
@@ -67,5 +68,5 @@
|
|
|
67
68
|
"publishConfig": {
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "d233507166f115f0253f2571590f32be095c3193"
|
|
71
72
|
}
|