@multiplatform.one/cli 7.83.1 → 7.84.0
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/lib/source.json +2 -2
- package/lib/source.mjs +7 -1
- package/package.json +2 -2
- package/scripts/scaffold.sh +21 -1
- package/src/source.ts +11 -0
- package/types/source.d.ts.map +1 -1
package/lib/source.json
CHANGED
package/lib/source.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { join, resolve } from "node:path";
|
|
|
5
5
|
|
|
6
6
|
//#region src/source.ts
|
|
7
7
|
const monorepoUrl = "https://git.corp.bitspur.com/multiplatform.one/mpo.git";
|
|
8
|
+
const corpHost = "git.corp.bitspur.com";
|
|
8
9
|
function isGitUrl(source) {
|
|
9
10
|
return /^(https?|ssh|git|file):\/\//.test(source) || /^[\w.-]+@[\w.-]+:/.test(source);
|
|
10
11
|
}
|
|
@@ -89,7 +90,12 @@ function classifySourceFailure(stderr) {
|
|
|
89
90
|
var SourceAccessError = class extends Error {
|
|
90
91
|
constructor(url, kind, gitOutput, reason) {
|
|
91
92
|
const host = /^[a-z]+:\/\/(?:[^@/]*@)?([^/:]+)/i.exec(url)?.[1] ?? /@([^:]+):/.exec(url)?.[1];
|
|
92
|
-
const
|
|
93
|
+
const corpPath = host === corpHost ? /^(?:[a-z+]+:\/\/(?:[^@/]*@)?[^/:]+(?::\d+)?\/|[^@]+@[^:]+:)(.+?)(?:\.git)?\/?$/i.exec(url)?.[1] : void 0;
|
|
94
|
+
const lines = kind === "network" ? [`Cannot reach the source repository ${url}${reason ? `: ${reason}` : ""}.`, `The CLI scaffolds from this git repository, so it needs a network path to ${host ?? "its host"} (check the connection, proxy or VPN).`] : [
|
|
95
|
+
`Cannot read the source repository ${url}${kind === "auth" ? ": access denied" : ""}.`,
|
|
96
|
+
...kind === "auth" && corpPath ? [`You need read access to ${corpPath} on ${corpHost}; ask the project owner.`] : [],
|
|
97
|
+
"The CLI scaffolds from this git repository, so it needs read access to it: an account that can clone it, and a credential git uses without asking (a token in a git credential helper for https, an SSH key for ssh)."
|
|
98
|
+
];
|
|
93
99
|
lines.push(`Check with: git ls-remote ${url}`);
|
|
94
100
|
lines.push("Or scaffold from a copy you can read: --source <path|url>");
|
|
95
101
|
const detail = gitOutput.split("\n").map((line) => line.trim()).filter(Boolean).slice(-4);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.84.0",
|
|
4
4
|
"description": "multiplatform.one cli — mpo init clones and prunes the monorepo, mpo update merges it back",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create-multiplatform-app",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@multiplatform.one/utils": "^7.
|
|
60
|
+
"@multiplatform.one/utils": "^7.84.0",
|
|
61
61
|
"commander": "^15.0.0",
|
|
62
62
|
"dotenv": "^17.4.2",
|
|
63
63
|
"inquirer": "^14.2.3",
|
package/scripts/scaffold.sh
CHANGED
|
@@ -747,6 +747,7 @@ done
|
|
|
747
747
|
[ -n "$PROJECT_NAME" ] || PROJECT_NAME="$(basename "$(cd "$TARGET" 2>/dev/null && pwd || printf '%s' "$TARGET")")"
|
|
748
748
|
node - "$TREE/package.json" "$PROJECT_NAME" "$APPS_CSV" "$REMOVED_CSV" "$(printf '%s' "$REMOVED" | tr ' ' ',')" <<'NODE'
|
|
749
749
|
const fs = require("node:fs");
|
|
750
|
+
const path = require("node:path");
|
|
750
751
|
const [file, projectName, appsCsv, removedCsv, prunedCsv] = process.argv.slice(2);
|
|
751
752
|
const apps = appsCsv ? appsCsv.split(",") : [];
|
|
752
753
|
const removed = removedCsv ? removedCsv.split(",") : [];
|
|
@@ -778,11 +779,30 @@ const cleanSegment = (segment) =>
|
|
|
778
779
|
);
|
|
779
780
|
// Each product app carries apps/one's design baseline; a pruned tree's
|
|
780
781
|
// baseline is gone, and a lint naming a missing baseline fails.
|
|
782
|
+
// A kept baseline can still record only pruned trees (packages' public and
|
|
783
|
+
// apps ratchets): the lint stats each path and dies on the first missing one.
|
|
784
|
+
const root = path.dirname(file);
|
|
785
|
+
const scansKeptTree = (baselineFile) => {
|
|
786
|
+
const full = path.join(root, baselineFile);
|
|
787
|
+
if (!fs.existsSync(full)) return true;
|
|
788
|
+
const baseline = JSON.parse(fs.readFileSync(full, "utf8"));
|
|
789
|
+
if (!Array.isArray(baseline.paths)) return true;
|
|
790
|
+
const kept = baseline.paths.filter((entry) => fs.existsSync(path.resolve(path.dirname(full), entry)));
|
|
791
|
+
if (!kept.length) {
|
|
792
|
+
fs.rmSync(full);
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
if (kept.length < baseline.paths.length) {
|
|
796
|
+
baseline.paths = kept;
|
|
797
|
+
fs.writeFileSync(full, `${JSON.stringify(baseline, null, 2)}\n`);
|
|
798
|
+
}
|
|
799
|
+
return true;
|
|
800
|
+
};
|
|
781
801
|
const designBaselines = (value) =>
|
|
782
802
|
value.replace(/\s--baseline\s+(\S+)/g, (whole, file) => {
|
|
783
803
|
if (file.startsWith("apps/one/"))
|
|
784
804
|
return apps.map((app) => ` --baseline apps/${app}/${file.slice("apps/one/".length)}`).join("");
|
|
785
|
-
return namesPruned(file) ? "" : whole;
|
|
805
|
+
return namesPruned(file) || !scansKeptTree(file) ? "" : whole;
|
|
786
806
|
});
|
|
787
807
|
const scripts = {};
|
|
788
808
|
for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
|
package/src/source.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { cliRoot, cliVersion } from "./commands/provenance";
|
|
|
5
5
|
|
|
6
6
|
export const monorepoUrl = "https://git.corp.bitspur.com/multiplatform.one/mpo.git";
|
|
7
7
|
|
|
8
|
+
const corpHost = "git.corp.bitspur.com";
|
|
9
|
+
|
|
8
10
|
export interface SourceSpec {
|
|
9
11
|
/** Path to a local clone, or a git URL. */
|
|
10
12
|
source: string;
|
|
@@ -126,6 +128,12 @@ export class SourceAccessError extends Error {
|
|
|
126
128
|
readonly gitOutput: string;
|
|
127
129
|
constructor(url: string, kind: SourceFailure, gitOutput: string, reason?: string) {
|
|
128
130
|
const host = /^[a-z]+:\/\/(?:[^@/]*@)?([^/:]+)/i.exec(url)?.[1] ?? /@([^:]+):/.exec(url)?.[1];
|
|
131
|
+
const corpPath =
|
|
132
|
+
host === corpHost
|
|
133
|
+
? /^(?:[a-z+]+:\/\/(?:[^@/]*@)?[^/:]+(?::\d+)?\/|[^@]+@[^:]+:)(.+?)(?:\.git)?\/?$/i.exec(
|
|
134
|
+
url,
|
|
135
|
+
)?.[1]
|
|
136
|
+
: undefined;
|
|
129
137
|
const lines =
|
|
130
138
|
kind === "network"
|
|
131
139
|
? [
|
|
@@ -134,6 +142,9 @@ export class SourceAccessError extends Error {
|
|
|
134
142
|
]
|
|
135
143
|
: [
|
|
136
144
|
`Cannot read the source repository ${url}${kind === "auth" ? ": access denied" : ""}.`,
|
|
145
|
+
...(kind === "auth" && corpPath
|
|
146
|
+
? [`You need read access to ${corpPath} on ${corpHost}; ask the project owner.`]
|
|
147
|
+
: []),
|
|
137
148
|
"The CLI scaffolds from this git repository, so it needs read access to it: an account that can clone it, and a credential git uses without asking (a token in a git credential helper for https, an SSH key for ssh).",
|
|
138
149
|
];
|
|
139
150
|
lines.push(`Check with: git ls-remote ${url}`);
|
package/types/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,2DAA2D,CAAC;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,2DAA2D,CAAC;AAIpF,MAAM,WAAW,UAAU;IACzB,2CA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