@multiplatform.one/cli 7.22.0 → 7.23.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/lib/bin/multiplatformOne.mjs +6 -306
- package/lib/commands/merge.mjs +10 -3
- package/lib/source.json +2 -2
- package/package.json +3 -2
- package/src/commands/merge.spec.ts +57 -2
- package/src/commands/merge.ts +13 -3
- package/types/commands/merge.d.ts +1 -1
- package/types/commands/merge.d.ts.map +1 -1
|
@@ -5,318 +5,18 @@ import { generateDoctypeTypes, typesDrift } from "../commands/doctypeTypes.mjs";
|
|
|
5
5
|
import { discoverE2EApp, runE2ESession } from "../commands/e2e.mjs";
|
|
6
6
|
import { SINGLETON_APPS, init } from "../commands/init.mjs";
|
|
7
7
|
import { updateApp } from "../commands/updateApp.mjs";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
8
|
import fsSync from "node:fs";
|
|
10
9
|
import path from "node:path";
|
|
11
10
|
import { fileURLToPath } from "node:url";
|
|
12
11
|
import fs from "node:fs/promises";
|
|
13
12
|
import { formatServiceList, lookupProjectRoot, waitForFrappe, waitForKeycloak, waitForPostgres, waitServices } from "@multiplatform.one/utils/dev";
|
|
14
13
|
import { Command } from "commander";
|
|
14
|
+
import dotenv from "dotenv";
|
|
15
15
|
import spawn from "nano-spawn";
|
|
16
16
|
import YAML from "yaml";
|
|
17
17
|
import yoctoSpinner from "yocto-spinner";
|
|
18
18
|
|
|
19
|
-
//#region \0rolldown/runtime.js
|
|
20
|
-
var __create = Object.create;
|
|
21
|
-
var __defProp = Object.defineProperty;
|
|
22
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
23
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
24
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
25
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
26
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
30
|
-
key = keys[i];
|
|
31
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
32
|
-
__defProp(to, key, {
|
|
33
|
-
get: ((k) => from[k]).bind(null, key),
|
|
34
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return to;
|
|
40
|
-
};
|
|
41
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
42
|
-
value: mod,
|
|
43
|
-
enumerable: true
|
|
44
|
-
}) : target, mod));
|
|
45
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region ../../node_modules/dotenv/lib/main.js
|
|
49
|
-
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
50
|
-
const fs$1 = __require("fs");
|
|
51
|
-
const path$1 = __require("path");
|
|
52
|
-
const os = __require("os");
|
|
53
|
-
const crypto = __require("crypto");
|
|
54
|
-
const TIPS = [
|
|
55
|
-
"◈ encrypted .env [www.dotenvx.com]",
|
|
56
|
-
"◈ secrets for agents [www.dotenvx.com]",
|
|
57
|
-
"⌁ auth for agents [www.vestauth.com]",
|
|
58
|
-
"⌘ custom filepath { path: '/custom/path/.env' }",
|
|
59
|
-
"⌘ enable debugging { debug: true }",
|
|
60
|
-
"⌘ override existing { override: true }",
|
|
61
|
-
"⌘ suppress logs { quiet: true }",
|
|
62
|
-
"⌘ multiple files { path: ['.env.local', '.env'] }"
|
|
63
|
-
];
|
|
64
|
-
function _getRandomTip() {
|
|
65
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
66
|
-
}
|
|
67
|
-
function parseBoolean(value) {
|
|
68
|
-
if (typeof value === "string") return ![
|
|
69
|
-
"false",
|
|
70
|
-
"0",
|
|
71
|
-
"no",
|
|
72
|
-
"off",
|
|
73
|
-
""
|
|
74
|
-
].includes(value.toLowerCase());
|
|
75
|
-
return Boolean(value);
|
|
76
|
-
}
|
|
77
|
-
function supportsAnsi() {
|
|
78
|
-
return process.stdout.isTTY;
|
|
79
|
-
}
|
|
80
|
-
function dim(text) {
|
|
81
|
-
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text;
|
|
82
|
-
}
|
|
83
|
-
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
84
|
-
function parse(src) {
|
|
85
|
-
const obj = {};
|
|
86
|
-
let lines = src.toString();
|
|
87
|
-
lines = lines.replace(/\r\n?/gm, "\n");
|
|
88
|
-
let match;
|
|
89
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
90
|
-
const key = match[1];
|
|
91
|
-
let value = match[2] || "";
|
|
92
|
-
value = value.trim();
|
|
93
|
-
const maybeQuote = value[0];
|
|
94
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
95
|
-
if (maybeQuote === "\"") {
|
|
96
|
-
value = value.replace(/\\n/g, "\n");
|
|
97
|
-
value = value.replace(/\\r/g, "\r");
|
|
98
|
-
}
|
|
99
|
-
obj[key] = value;
|
|
100
|
-
}
|
|
101
|
-
return obj;
|
|
102
|
-
}
|
|
103
|
-
function _parseVault(options) {
|
|
104
|
-
options = options || {};
|
|
105
|
-
const vaultPath = _vaultPath(options);
|
|
106
|
-
options.path = vaultPath;
|
|
107
|
-
const result = DotenvModule.configDotenv(options);
|
|
108
|
-
if (!result.parsed) {
|
|
109
|
-
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
110
|
-
err.code = "MISSING_DATA";
|
|
111
|
-
throw err;
|
|
112
|
-
}
|
|
113
|
-
const keys = _dotenvKey(options).split(",");
|
|
114
|
-
const length = keys.length;
|
|
115
|
-
let decrypted;
|
|
116
|
-
for (let i = 0; i < length; i++) try {
|
|
117
|
-
const attrs = _instructions(result, keys[i].trim());
|
|
118
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
119
|
-
break;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (i + 1 >= length) throw error;
|
|
122
|
-
}
|
|
123
|
-
return DotenvModule.parse(decrypted);
|
|
124
|
-
}
|
|
125
|
-
function _warn(message) {
|
|
126
|
-
console.error(`⚠ ${message}`);
|
|
127
|
-
}
|
|
128
|
-
function _debug(message) {
|
|
129
|
-
console.log(`┆ ${message}`);
|
|
130
|
-
}
|
|
131
|
-
function _log(message) {
|
|
132
|
-
console.log(`◇ ${message}`);
|
|
133
|
-
}
|
|
134
|
-
function _dotenvKey(options) {
|
|
135
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
|
|
136
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
137
|
-
return "";
|
|
138
|
-
}
|
|
139
|
-
function _instructions(result, dotenvKey) {
|
|
140
|
-
let uri;
|
|
141
|
-
try {
|
|
142
|
-
uri = new URL(dotenvKey);
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
145
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
146
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
147
|
-
throw err;
|
|
148
|
-
}
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
const key = uri.password;
|
|
152
|
-
if (!key) {
|
|
153
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
154
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
155
|
-
throw err;
|
|
156
|
-
}
|
|
157
|
-
const environment = uri.searchParams.get("environment");
|
|
158
|
-
if (!environment) {
|
|
159
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
160
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
161
|
-
throw err;
|
|
162
|
-
}
|
|
163
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
164
|
-
const ciphertext = result.parsed[environmentKey];
|
|
165
|
-
if (!ciphertext) {
|
|
166
|
-
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
167
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
168
|
-
throw err;
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
ciphertext,
|
|
172
|
-
key
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function _vaultPath(options) {
|
|
176
|
-
let possibleVaultPath = null;
|
|
177
|
-
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
178
|
-
for (const filepath of options.path) if (fs$1.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
179
|
-
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
180
|
-
else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
|
|
181
|
-
if (fs$1.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
function _resolveHome(envPath) {
|
|
185
|
-
return envPath[0] === "~" ? path$1.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
186
|
-
}
|
|
187
|
-
function _configVault(options) {
|
|
188
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
189
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
190
|
-
if (debug || !quiet) _log("loading env from encrypted .env.vault");
|
|
191
|
-
const parsed = DotenvModule._parseVault(options);
|
|
192
|
-
let processEnv = process.env;
|
|
193
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
194
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
195
|
-
return { parsed };
|
|
196
|
-
}
|
|
197
|
-
function configDotenv(options) {
|
|
198
|
-
const dotenvPath = path$1.resolve(process.cwd(), ".env");
|
|
199
|
-
let encoding = "utf8";
|
|
200
|
-
let processEnv = process.env;
|
|
201
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
202
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
203
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
204
|
-
if (options && options.encoding) encoding = options.encoding;
|
|
205
|
-
else if (debug) _debug("no encoding is specified (UTF-8 is used by default)");
|
|
206
|
-
let optionPaths = [dotenvPath];
|
|
207
|
-
if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
|
|
208
|
-
else {
|
|
209
|
-
optionPaths = [];
|
|
210
|
-
for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
|
|
211
|
-
}
|
|
212
|
-
let lastError;
|
|
213
|
-
const parsedAll = {};
|
|
214
|
-
for (const path of optionPaths) try {
|
|
215
|
-
const parsed = DotenvModule.parse(fs$1.readFileSync(path, { encoding }));
|
|
216
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
217
|
-
} catch (e) {
|
|
218
|
-
if (debug) _debug(`failed to load ${path} ${e.message}`);
|
|
219
|
-
lastError = e;
|
|
220
|
-
}
|
|
221
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
222
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
223
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
224
|
-
if (debug || !quiet) {
|
|
225
|
-
const keysCount = Object.keys(populated).length;
|
|
226
|
-
const shortPaths = [];
|
|
227
|
-
for (const filePath of optionPaths) try {
|
|
228
|
-
const relative = path$1.relative(process.cwd(), filePath);
|
|
229
|
-
shortPaths.push(relative);
|
|
230
|
-
} catch (e) {
|
|
231
|
-
if (debug) _debug(`failed to load ${filePath} ${e.message}`);
|
|
232
|
-
lastError = e;
|
|
233
|
-
}
|
|
234
|
-
_log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
235
|
-
}
|
|
236
|
-
if (lastError) return {
|
|
237
|
-
parsed: parsedAll,
|
|
238
|
-
error: lastError
|
|
239
|
-
};
|
|
240
|
-
else return { parsed: parsedAll };
|
|
241
|
-
}
|
|
242
|
-
function config(options) {
|
|
243
|
-
if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
|
|
244
|
-
const vaultPath = _vaultPath(options);
|
|
245
|
-
if (!vaultPath) {
|
|
246
|
-
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
247
|
-
return DotenvModule.configDotenv(options);
|
|
248
|
-
}
|
|
249
|
-
return DotenvModule._configVault(options);
|
|
250
|
-
}
|
|
251
|
-
function decrypt(encrypted, keyStr) {
|
|
252
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
253
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
254
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
255
|
-
const authTag = ciphertext.subarray(-16);
|
|
256
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
257
|
-
try {
|
|
258
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
259
|
-
aesgcm.setAuthTag(authTag);
|
|
260
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
261
|
-
} catch (error) {
|
|
262
|
-
const isRange = error instanceof RangeError;
|
|
263
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
264
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
265
|
-
if (isRange || invalidKeyLength) {
|
|
266
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
267
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
268
|
-
throw err;
|
|
269
|
-
} else if (decryptionFailed) {
|
|
270
|
-
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
271
|
-
err.code = "DECRYPTION_FAILED";
|
|
272
|
-
throw err;
|
|
273
|
-
} else throw error;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function populate(processEnv, parsed, options = {}) {
|
|
277
|
-
const debug = Boolean(options && options.debug);
|
|
278
|
-
const override = Boolean(options && options.override);
|
|
279
|
-
const populated = {};
|
|
280
|
-
if (typeof parsed !== "object") {
|
|
281
|
-
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
282
|
-
err.code = "OBJECT_REQUIRED";
|
|
283
|
-
throw err;
|
|
284
|
-
}
|
|
285
|
-
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
286
|
-
if (override === true) {
|
|
287
|
-
processEnv[key] = parsed[key];
|
|
288
|
-
populated[key] = parsed[key];
|
|
289
|
-
}
|
|
290
|
-
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
291
|
-
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
292
|
-
} else {
|
|
293
|
-
processEnv[key] = parsed[key];
|
|
294
|
-
populated[key] = parsed[key];
|
|
295
|
-
}
|
|
296
|
-
return populated;
|
|
297
|
-
}
|
|
298
|
-
const DotenvModule = {
|
|
299
|
-
configDotenv,
|
|
300
|
-
_configVault,
|
|
301
|
-
_parseVault,
|
|
302
|
-
config,
|
|
303
|
-
decrypt,
|
|
304
|
-
parse,
|
|
305
|
-
populate
|
|
306
|
-
};
|
|
307
|
-
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
308
|
-
module.exports._configVault = DotenvModule._configVault;
|
|
309
|
-
module.exports._parseVault = DotenvModule._parseVault;
|
|
310
|
-
module.exports.config = DotenvModule.config;
|
|
311
|
-
module.exports.decrypt = DotenvModule.decrypt;
|
|
312
|
-
module.exports.parse = DotenvModule.parse;
|
|
313
|
-
module.exports.populate = DotenvModule.populate;
|
|
314
|
-
module.exports = DotenvModule;
|
|
315
|
-
}));
|
|
316
|
-
|
|
317
|
-
//#endregion
|
|
318
19
|
//#region src/bin/multiplatformOne.ts
|
|
319
|
-
var import_main = /* @__PURE__ */ __toESM(require_main(), 1);
|
|
320
20
|
const projectRoot = lookupProjectRoot();
|
|
321
21
|
const availableServices = [
|
|
322
22
|
"api",
|
|
@@ -516,7 +216,7 @@ program.command("update").option("--source <path|url>", "monorepo to update from
|
|
|
516
216
|
});
|
|
517
217
|
});
|
|
518
218
|
program.command("wait").description("wait for a service to be ready").option("-i, --interval <interval>", "interval to wait for", "1000").option("-t, --timeout <timeout>", "timeout to wait for", "600000").option("-e, --dotenv <dotenv>", "dotenv file path", ".env").argument("<services>", `the services to wait for (${waitServices.join(", ")})`).action(async (servicesString, options) => {
|
|
519
|
-
|
|
219
|
+
dotenv.config({ path: options.dotenv || defaultDotenvPath });
|
|
520
220
|
const interval = Number.parseInt(options.interval);
|
|
521
221
|
const timeout = Number.parseInt(options.timeout);
|
|
522
222
|
const services = servicesString.split(",");
|
|
@@ -532,7 +232,7 @@ program.command("wait").description("wait for a service to be ready").option("-i
|
|
|
532
232
|
const frappe = program.command("frappe").description("manage frappe development environment").option("-e, --dotenv <dotenv>", "dotenv file path", ".env");
|
|
533
233
|
frappe.command("bootstrap").description("bootstrap frappe development environment").option("-u, --update", "update dependencies").action(async (options) => {
|
|
534
234
|
const parentOptions = frappe.opts();
|
|
535
|
-
|
|
235
|
+
dotenv.config({ path: parentOptions.dotenv || defaultDotenvPath });
|
|
536
236
|
await spawn("sh", [
|
|
537
237
|
path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/frappe.sh"),
|
|
538
238
|
"bootstrap",
|
|
@@ -556,7 +256,7 @@ frappe.command("clean").description("clean frappe bench artifacts").option("--ca
|
|
|
556
256
|
});
|
|
557
257
|
frappe.command("dev").description("start frappe development server").action(async () => {
|
|
558
258
|
const parentOptions = frappe.opts();
|
|
559
|
-
|
|
259
|
+
dotenv.config({ path: parentOptions.dotenv || defaultDotenvPath });
|
|
560
260
|
await spawn("sh", [path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/frappe.sh"), "dev"], {
|
|
561
261
|
stdio: "inherit",
|
|
562
262
|
shell: true,
|
|
@@ -565,7 +265,7 @@ frappe.command("dev").description("start frappe development server").action(asyn
|
|
|
565
265
|
});
|
|
566
266
|
frappe.command("bench").description("run bench command").action(async () => {
|
|
567
267
|
const parentOptions = frappe.opts();
|
|
568
|
-
|
|
268
|
+
dotenv.config({ path: parentOptions.dotenv || defaultDotenvPath });
|
|
569
269
|
await spawn("sh", [path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/frappe.sh"), "bench"], {
|
|
570
270
|
stdio: "inherit",
|
|
571
271
|
shell: true,
|
|
@@ -574,7 +274,7 @@ frappe.command("bench").description("run bench command").action(async () => {
|
|
|
574
274
|
});
|
|
575
275
|
frappe.command("types").description("generate TypeScript types for doctypes from getdoctype (auth: $FRAPPE_API_KEY, $FRAPPE_API_SECRET)").argument("<doctypes...>", "doctype names; child tables come along").option("-o, --out <file>", "write the module here instead of stdout").option("--check", "exit 1 and print the diff when --out differs from the server").option("--url <url>", "frappe base URL (default $FRAPPE_URL or http://localhost:8000)").action(async (doctypes, options) => {
|
|
576
276
|
const parentOptions = frappe.opts();
|
|
577
|
-
|
|
277
|
+
dotenv.config({
|
|
578
278
|
path: parentOptions.dotenv || defaultDotenvPath,
|
|
579
279
|
quiet: true
|
|
580
280
|
});
|
package/lib/commands/merge.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { tmpdir } from "node:os";
|
|
|
11
11
|
* ours = the project's HEAD (every commit the project made)
|
|
12
12
|
* theirs = the scaffold it is moving to
|
|
13
13
|
*
|
|
14
|
-
* `git merge-tree --write-tree
|
|
14
|
+
* `git merge-tree --write-tree` (git 2.38+) merges the scaffold's
|
|
15
15
|
* evolution with the project's history; the result lands in the index and
|
|
16
16
|
* worktree, never in a commit, so the project commits when it is happy.
|
|
17
17
|
* `.updateignore` entries (exact files or directory prefixes, not globs) and
|
|
@@ -296,6 +296,14 @@ async function mergeScaffolds(request) {
|
|
|
296
296
|
const head = await gitOut(projectDir, ["rev-parse", "HEAD"]);
|
|
297
297
|
const baseCommit = request.baseDir ? await commitTreeFromDir(projectDir, request.baseDir, request.baseLabel) : await emptyCommit(projectDir, request.baseLabel);
|
|
298
298
|
const nextCommit = await commitTreeFromDir(projectDir, request.theirsDir, request.theirsLabel, baseCommit);
|
|
299
|
+
const oursCommit = await gitOut(projectDir, [
|
|
300
|
+
"commit-tree",
|
|
301
|
+
`${head}^{tree}`,
|
|
302
|
+
"-p",
|
|
303
|
+
baseCommit,
|
|
304
|
+
"-m",
|
|
305
|
+
"HEAD"
|
|
306
|
+
]);
|
|
299
307
|
let mergedTree;
|
|
300
308
|
let conflicts = [];
|
|
301
309
|
try {
|
|
@@ -303,8 +311,7 @@ async function mergeScaffolds(request) {
|
|
|
303
311
|
"merge-tree",
|
|
304
312
|
"--write-tree",
|
|
305
313
|
"--name-only",
|
|
306
|
-
|
|
307
|
-
head,
|
|
314
|
+
oursCommit,
|
|
308
315
|
nextCommit
|
|
309
316
|
])).split("\n")[0].trim();
|
|
310
317
|
} catch (err) {
|
package/lib/source.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.1",
|
|
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",
|
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@multiplatform.one/utils": "7.
|
|
59
|
+
"@multiplatform.one/utils": "7.23.1",
|
|
60
60
|
"commander": "^14.0.3",
|
|
61
|
+
"dotenv": "^17.4.2",
|
|
61
62
|
"inquirer": "^13.4.2",
|
|
62
63
|
"nano-spawn": "^2.1.0",
|
|
63
64
|
"yaml": "^2.8.3",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import spawn from "nano-spawn";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { gitOut, mergeScaffolds, threeWayMergePackageJson } from "./merge";
|
|
3
7
|
|
|
4
8
|
const json = (value: unknown) => JSON.stringify(value, null, 2);
|
|
5
9
|
|
|
@@ -79,3 +83,54 @@ describe("threeWayMergePackageJson", () => {
|
|
|
79
83
|
});
|
|
80
84
|
});
|
|
81
85
|
});
|
|
86
|
+
|
|
87
|
+
describe("mergeScaffolds on git 2.38 and 2.39, whose merge-tree has no --merge-base", () => {
|
|
88
|
+
const scratch: string[] = [];
|
|
89
|
+
const path = process.env.PATH;
|
|
90
|
+
|
|
91
|
+
afterEach(() => {
|
|
92
|
+
process.env.PATH = path;
|
|
93
|
+
for (const dir of scratch.splice(0)) rmSync(dir, { recursive: true, force: true });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
function tempDir(files: Record<string, string> = {}): string {
|
|
97
|
+
const dir = mkdtempSync(join(tmpdir(), "mpo-merge-spec-"));
|
|
98
|
+
scratch.push(dir);
|
|
99
|
+
for (const [name, content] of Object.entries(files)) writeFileSync(join(dir, name), content);
|
|
100
|
+
return dir;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
it("merges the scaffold's change into the project through history alone", async () => {
|
|
104
|
+
const shim = tempDir({
|
|
105
|
+
git: `#!/bin/sh\nfor arg in "$@"; do\n case $arg in --merge-base*) exit 129 ;; esac\ndone\nPATH='${path}' exec git "$@"\n`,
|
|
106
|
+
});
|
|
107
|
+
chmodSync(join(shim, "git"), 0o755);
|
|
108
|
+
|
|
109
|
+
const project = tempDir({ "a.txt": "one\n", "b.txt": "b\n", "mine.txt": "mine\n" });
|
|
110
|
+
await spawn("git", ["init", "--quiet"], { cwd: project });
|
|
111
|
+
await spawn("git", ["config", "user.email", "spec@example.com"], { cwd: project });
|
|
112
|
+
await spawn("git", ["config", "user.name", "Spec"], { cwd: project });
|
|
113
|
+
await spawn("git", ["add", "-A"], { cwd: project });
|
|
114
|
+
await spawn("git", ["commit", "--quiet", "-m", "project"], { cwd: project });
|
|
115
|
+
|
|
116
|
+
process.env.PATH = `${shim}:${path}`;
|
|
117
|
+
await expect(
|
|
118
|
+
spawn("git", ["merge-tree", "--write-tree", "--merge-base=HEAD", "HEAD", "HEAD"], {
|
|
119
|
+
cwd: project,
|
|
120
|
+
}),
|
|
121
|
+
).rejects.toMatchObject({ exitCode: 129 });
|
|
122
|
+
|
|
123
|
+
const outcome = await mergeScaffolds({
|
|
124
|
+
projectDir: project,
|
|
125
|
+
baseDir: tempDir({ "a.txt": "one\n", "b.txt": "b\n" }),
|
|
126
|
+
theirsDir: tempDir({ "a.txt": "two\n", "b.txt": "b\n" }),
|
|
127
|
+
baseLabel: "scaffold 1",
|
|
128
|
+
theirsLabel: "scaffold 2",
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
expect(outcome.conflicts).toEqual([]);
|
|
132
|
+
expect(outcome.changed).toBe(true);
|
|
133
|
+
expect(await gitOut(project, ["show", `${outcome.mergedTree}:a.txt`])).toBe("two");
|
|
134
|
+
expect(await gitOut(project, ["show", `${outcome.mergedTree}:mine.txt`])).toBe("mine");
|
|
135
|
+
});
|
|
136
|
+
});
|
package/src/commands/merge.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ours = the project's HEAD (every commit the project made)
|
|
6
6
|
* theirs = the scaffold it is moving to
|
|
7
7
|
*
|
|
8
|
-
* `git merge-tree --write-tree
|
|
8
|
+
* `git merge-tree --write-tree` (git 2.38+) merges the scaffold's
|
|
9
9
|
* evolution with the project's history; the result lands in the index and
|
|
10
10
|
* worktree, never in a commit, so the project commits when it is happy.
|
|
11
11
|
* `.updateignore` entries (exact files or directory prefixes, not globs) and
|
|
@@ -324,6 +324,17 @@ export async function mergeScaffolds(request: MergeRequest): Promise<MergeOutcom
|
|
|
324
324
|
request.theirsLabel,
|
|
325
325
|
baseCommit,
|
|
326
326
|
);
|
|
327
|
+
// merge-tree reads --merge-base only from git 2.40, and Debian bookworm
|
|
328
|
+
// ships 2.39. HEAD's tree on a commit parented by the base hands it the
|
|
329
|
+
// same base through history instead.
|
|
330
|
+
const oursCommit = await gitOut(projectDir, [
|
|
331
|
+
"commit-tree",
|
|
332
|
+
`${head}^{tree}`,
|
|
333
|
+
"-p",
|
|
334
|
+
baseCommit,
|
|
335
|
+
"-m",
|
|
336
|
+
"HEAD",
|
|
337
|
+
]);
|
|
327
338
|
|
|
328
339
|
let mergedTree: string;
|
|
329
340
|
let conflicts: string[] = [];
|
|
@@ -332,8 +343,7 @@ export async function mergeScaffolds(request: MergeRequest): Promise<MergeOutcom
|
|
|
332
343
|
"merge-tree",
|
|
333
344
|
"--write-tree",
|
|
334
345
|
"--name-only",
|
|
335
|
-
|
|
336
|
-
head,
|
|
346
|
+
oursCommit,
|
|
337
347
|
nextCommit,
|
|
338
348
|
]);
|
|
339
349
|
mergedTree = out.split("\n")[0]!.trim();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ours = the project's HEAD (every commit the project made)
|
|
6
6
|
* theirs = the scaffold it is moving to
|
|
7
7
|
*
|
|
8
|
-
* `git merge-tree --write-tree
|
|
8
|
+
* `git merge-tree --write-tree` (git 2.38+) merges the scaffold's
|
|
9
9
|
* evolution with the project's history; the result lands in the index and
|
|
10
10
|
* worktree, never in a commit, so the project commits when it is happy.
|
|
11
11
|
* `.updateignore` entries (exact files or directory prefixes, not globs) and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,wBAAsB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,wCAKzF;AAED,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBAG5F;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpE;AAED,+EAA+E;AAC/E,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzF;AAuED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBrD;AA2ED;0EAC0E;AAC1E,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI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