@todesktop/cli 1.15.2 → 1.18.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/README.md +55 -3
- package/dist/cli.js +779 -149
- package/dist/cli.js.map +4 -4
- package/dist/types.d.ts +28 -0
- package/package.json +15 -25
- package/schemas/schema.json +45 -1
- package/scripts/postinstall.js +0 -19
package/dist/cli.js
CHANGED
|
@@ -192,12 +192,19 @@ var firebaseApp = (0, import_app.initializeApp)({
|
|
|
192
192
|
});
|
|
193
193
|
var auth = (0, import_auth.getAuth)(firebaseApp);
|
|
194
194
|
var db = (0, import_firestore.getFirestore)(firebaseApp);
|
|
195
|
-
var
|
|
195
|
+
var _a;
|
|
196
|
+
var [host, port] = ((_a = environmentVariables.TODESKTOP_CLI_FIRESTORE_HOST) == null ? void 0 : _a.split(":")) || [];
|
|
197
|
+
if (host && port) {
|
|
198
|
+
(0, import_firestore.connectFirestoreEmulator)(db, host, Number.parseInt(port, 10));
|
|
199
|
+
}
|
|
200
|
+
var currentUser = () => {
|
|
201
|
+
return auth.currentUser;
|
|
202
|
+
};
|
|
196
203
|
var signInWithCustomToken = async (token) => {
|
|
197
204
|
return (0, import_auth.signInWithCustomToken)(auth, token);
|
|
198
205
|
};
|
|
199
206
|
var onUserAuth = (handler) => (0, import_auth.onAuthStateChanged)(auth, (user) => {
|
|
200
|
-
handler(user
|
|
207
|
+
handler(user ?? {});
|
|
201
208
|
});
|
|
202
209
|
var firestore_default = db;
|
|
203
210
|
|
|
@@ -322,7 +329,7 @@ var track = (event, properties = {}, callback = () => {
|
|
|
322
329
|
analytics.track(
|
|
323
330
|
{
|
|
324
331
|
event,
|
|
325
|
-
userId: user
|
|
332
|
+
userId: user == null ? void 0 : user.uid,
|
|
326
333
|
anonymousId,
|
|
327
334
|
properties: {
|
|
328
335
|
...properties,
|
|
@@ -380,10 +387,10 @@ function fixMacUrl(url) {
|
|
|
380
387
|
// src/components/BuildCompleteMessage.tsx
|
|
381
388
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
382
389
|
var BuildCompleteMessage = ({ build }) => {
|
|
383
|
-
var
|
|
390
|
+
var _a2;
|
|
384
391
|
const exit = useExit_default();
|
|
385
392
|
let url = build.standardUniversalDownloadUrl;
|
|
386
|
-
if (process.platform === "darwin" && ((
|
|
393
|
+
if (process.platform === "darwin" && ((_a2 = build.mac) == null ? void 0 : _a2.standardDownloadUrl)) {
|
|
387
394
|
url = fixMacUrl(build.mac.standardDownloadUrl);
|
|
388
395
|
}
|
|
389
396
|
logForCI_default(`Build complete! ${url}`);
|
|
@@ -565,18 +572,18 @@ var import_ink5 = require("ink");
|
|
|
565
572
|
var import_react3 = require("react");
|
|
566
573
|
|
|
567
574
|
// src/utilities/CliError.ts
|
|
568
|
-
var CliError = class extends Error {
|
|
575
|
+
var CliError = class _CliError extends Error {
|
|
569
576
|
constructor(message2, { cause, type = "error" } = {}) {
|
|
570
577
|
super(message2, { cause });
|
|
571
578
|
this.type = type;
|
|
572
579
|
}
|
|
573
580
|
static from(e, type = "error") {
|
|
574
581
|
if (e instanceof Error) {
|
|
575
|
-
return new
|
|
582
|
+
return new _CliError(e.message, { cause: e, type });
|
|
576
583
|
} else if (typeof e === "string") {
|
|
577
|
-
return new
|
|
584
|
+
return new _CliError(e, { type });
|
|
578
585
|
} else {
|
|
579
|
-
return new
|
|
586
|
+
return new _CliError(JSON.stringify(e), { type });
|
|
580
587
|
}
|
|
581
588
|
}
|
|
582
589
|
};
|
|
@@ -647,8 +654,9 @@ var app = (0, import_app2.initializeApp)({
|
|
|
647
654
|
appId: env.TODESKTOP_CLI_FIREBASE_ID
|
|
648
655
|
});
|
|
649
656
|
var functions = (0, import_functions.getFunctions)(app);
|
|
650
|
-
|
|
651
|
-
|
|
657
|
+
var firebaseFunctionsBase = env.TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE || "";
|
|
658
|
+
if (firebaseFunctionsBase.includes("localhost")) {
|
|
659
|
+
const firebaseUrl = new URL(firebaseFunctionsBase);
|
|
652
660
|
(0, import_functions.connectFunctionsEmulator)(
|
|
653
661
|
functions,
|
|
654
662
|
firebaseUrl.hostname,
|
|
@@ -1016,9 +1024,13 @@ async function postToFirebaseFunction_default(functionName, body = {}, config2 =
|
|
|
1016
1024
|
{ scrub: { functionName, body, config: config2 } },
|
|
1017
1025
|
"postToFirebaseFunction"
|
|
1018
1026
|
);
|
|
1027
|
+
let baseUrl = TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE;
|
|
1028
|
+
if (!baseUrl.endsWith("/")) {
|
|
1029
|
+
baseUrl += "/";
|
|
1030
|
+
}
|
|
1019
1031
|
try {
|
|
1020
1032
|
const response = await import_axios.default.post(
|
|
1021
|
-
`${
|
|
1033
|
+
`${baseUrl}${functionName}`,
|
|
1022
1034
|
body,
|
|
1023
1035
|
config2
|
|
1024
1036
|
);
|
|
@@ -1062,8 +1074,8 @@ function loadTypeScriptConfig(configPath) {
|
|
|
1062
1074
|
);
|
|
1063
1075
|
}
|
|
1064
1076
|
}
|
|
1065
|
-
const
|
|
1066
|
-
const sourceCode =
|
|
1077
|
+
const fs7 = require("fs");
|
|
1078
|
+
const sourceCode = fs7.readFileSync(configPath, "utf8");
|
|
1067
1079
|
const result = typescript.transpile(sourceCode, {
|
|
1068
1080
|
target: typescript.ScriptTarget.ES2018,
|
|
1069
1081
|
module: typescript.ModuleKind.CommonJS,
|
|
@@ -1643,6 +1655,21 @@ var schema_default = {
|
|
|
1643
1655
|
appFiles: { $ref: "#/definitions/appFilesProperty" },
|
|
1644
1656
|
appProtocolScheme: { $ref: "#/definitions/appProtocolSchemeProperty" },
|
|
1645
1657
|
appPath: { $ref: "#/definitions/appPathProperty" },
|
|
1658
|
+
bundleWorkspacePackages: {
|
|
1659
|
+
type: "object",
|
|
1660
|
+
additionalProperties: false,
|
|
1661
|
+
description: "Useful when your application is a monorepo (e.g. pnpm workspaces). You can configure whether the CLI bundles workspace packages alongside the app upload. When enabled, workspace dependencies referenced via `workspace:` or local `file:` specifiers are bundled with your application upload and dependency ranges are rewritten to `file:` paths so they install deterministically on the build servers.",
|
|
1662
|
+
examples: ['{"enabled":true}'],
|
|
1663
|
+
default: { enabled: false },
|
|
1664
|
+
properties: {
|
|
1665
|
+
enabled: {
|
|
1666
|
+
type: "boolean",
|
|
1667
|
+
default: false,
|
|
1668
|
+
description: "Enable automatic bundling of workspace packages for this project."
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
},
|
|
1672
|
+
bytenode: { $ref: "#/definitions/bytenodeConfigProperty" },
|
|
1646
1673
|
asar: { $ref: "#/definitions/asarProperty" },
|
|
1647
1674
|
asarUnpack: { $ref: "#/definitions/asarUnpackProperty" },
|
|
1648
1675
|
buildVersion: { $ref: "#/definitions/buildVersionProperty" },
|
|
@@ -1735,6 +1762,34 @@ var schema_default = {
|
|
|
1735
1762
|
examples: ["com.microsoft.word"],
|
|
1736
1763
|
default: "auto-generated"
|
|
1737
1764
|
},
|
|
1765
|
+
bytenodeConfigProperty: {
|
|
1766
|
+
type: "object",
|
|
1767
|
+
additionalProperties: false,
|
|
1768
|
+
description: "Compile selected source files to .jsc using Bytenode during the build. Provide glob patterns relative to your appPath.",
|
|
1769
|
+
default: { enabled: false },
|
|
1770
|
+
properties: {
|
|
1771
|
+
enabled: {
|
|
1772
|
+
type: "boolean",
|
|
1773
|
+
default: false,
|
|
1774
|
+
description: "Enable Bytenode compilation."
|
|
1775
|
+
},
|
|
1776
|
+
files: {
|
|
1777
|
+
type: "array",
|
|
1778
|
+
items: { type: "string", minLength: 1 },
|
|
1779
|
+
minItems: 1,
|
|
1780
|
+
description: "Glob patterns relative to appPath for files to compile to Bytenode."
|
|
1781
|
+
}
|
|
1782
|
+
},
|
|
1783
|
+
allOf: [
|
|
1784
|
+
{
|
|
1785
|
+
if: {
|
|
1786
|
+
properties: { enabled: { const: true } },
|
|
1787
|
+
required: ["enabled"]
|
|
1788
|
+
},
|
|
1789
|
+
then: { required: ["files"] }
|
|
1790
|
+
}
|
|
1791
|
+
]
|
|
1792
|
+
},
|
|
1738
1793
|
appFilesProperty: {
|
|
1739
1794
|
type: "array",
|
|
1740
1795
|
description: "This option allows you to decide which files get uploaded to be built on the ToDesktop servers. By default, all files in your app path are included in your app, except for `node_modules` and `.git`. Dependencies are installed on our build servers as there could be platform-specific postinstall steps.",
|
|
@@ -2418,7 +2473,7 @@ var schema_default = {
|
|
|
2418
2473
|
description: "The path to your application's Windows desktop icon. It must be an ICO, ICNS, or PNG.",
|
|
2419
2474
|
examples: ["./icon.ico"],
|
|
2420
2475
|
file: {
|
|
2421
|
-
extensions: ["icns", "png", "
|
|
2476
|
+
extensions: ["icns", "png", "ico"],
|
|
2422
2477
|
mustBeFile: true
|
|
2423
2478
|
},
|
|
2424
2479
|
minLength: 3
|
|
@@ -2483,6 +2538,7 @@ var schema_default = {
|
|
|
2483
2538
|
$ref: "#/definitions/appProtocolSchemeProperty"
|
|
2484
2539
|
},
|
|
2485
2540
|
appPath: { $ref: "#/definitions/appPathProperty" },
|
|
2541
|
+
bytenode: { $ref: "#/definitions/bytenodeConfigProperty" },
|
|
2486
2542
|
asar: { $ref: "#/definitions/asarProperty" },
|
|
2487
2543
|
asarUnpack: { $ref: "#/definitions/asarUnpackProperty" },
|
|
2488
2544
|
buildVersion: { $ref: "#/definitions/buildVersionProperty" },
|
|
@@ -2635,6 +2691,9 @@ function getProjectConfig(configPath, flags) {
|
|
|
2635
2691
|
const config2 = computeFullProjectConfig(partialConfig, projectRoot, flags);
|
|
2636
2692
|
validateConfig({ config: config2, projectRoot });
|
|
2637
2693
|
const result = resolveConfigPaths({ config: config2, projectRoot });
|
|
2694
|
+
if (process.env.TODESKTOP_CLI_APP_ID) {
|
|
2695
|
+
result.id = process.env.TODESKTOP_CLI_APP_ID;
|
|
2696
|
+
}
|
|
2638
2697
|
return { config: result, unprocessedConfig: config2, projectRoot };
|
|
2639
2698
|
}
|
|
2640
2699
|
|
|
@@ -2705,6 +2764,19 @@ var getVersionControlInfo_default = async (directory) => {
|
|
|
2705
2764
|
// src/commands/build/utilities/spyBuild.ts
|
|
2706
2765
|
var import_events = __toESM(require("events"));
|
|
2707
2766
|
var import_firestore3 = require("firebase/firestore");
|
|
2767
|
+
|
|
2768
|
+
// src/utilities/firestoreData.ts
|
|
2769
|
+
var readQueryDocument = (doc9) => {
|
|
2770
|
+
return doc9.data();
|
|
2771
|
+
};
|
|
2772
|
+
var readDocumentSnapshot = (snapshot) => {
|
|
2773
|
+
return snapshot.exists() ? snapshot.data() : void 0;
|
|
2774
|
+
};
|
|
2775
|
+
var readQuerySnapshot = (snapshot) => {
|
|
2776
|
+
return snapshot.docs.map((doc9) => readQueryDocument(doc9));
|
|
2777
|
+
};
|
|
2778
|
+
|
|
2779
|
+
// src/commands/build/utilities/spyBuild.ts
|
|
2708
2780
|
function spyBuild() {
|
|
2709
2781
|
const emitter = new import_events.default();
|
|
2710
2782
|
let unsubscribeSnapshot;
|
|
@@ -2734,7 +2806,7 @@ function spyBuild() {
|
|
|
2734
2806
|
unsubscribeSnapshot = (0, import_firestore3.onSnapshot)(
|
|
2735
2807
|
(0, import_firestore3.doc)(firestore_default, buildPath),
|
|
2736
2808
|
(snapshot) => {
|
|
2737
|
-
latestBuildDoc =
|
|
2809
|
+
latestBuildDoc = readDocumentSnapshot(snapshot);
|
|
2738
2810
|
emitter.emit("update", {
|
|
2739
2811
|
build: latestBuildDoc,
|
|
2740
2812
|
snapshot
|
|
@@ -2764,16 +2836,16 @@ function spyBuild() {
|
|
|
2764
2836
|
function buildHasSettled(build) {
|
|
2765
2837
|
return ["linux", "mac", "windows"].every(
|
|
2766
2838
|
(platform) => {
|
|
2767
|
-
var
|
|
2768
|
-
return ((
|
|
2839
|
+
var _a2, _b, _c, _d, _e;
|
|
2840
|
+
return ((_a2 = build[platform]) == null ? void 0 : _a2.shouldSkip) || "succeeded" === ((_b = build[platform]) == null ? void 0 : _b.status) || "cancelled" === ((_c = build[platform]) == null ? void 0 : _c.status) || "failed" === ((_d = build[platform]) == null ? void 0 : _d.status) && ((_e = build[platform]) == null ? void 0 : _e.numberOfAttemptedBuilds) === 2;
|
|
2769
2841
|
}
|
|
2770
2842
|
);
|
|
2771
2843
|
}
|
|
2772
2844
|
|
|
2773
2845
|
// src/commands/build/utilities/uploadApplicationSource.ts
|
|
2774
|
-
var
|
|
2775
|
-
var
|
|
2776
|
-
var
|
|
2846
|
+
var import_fast_glob2 = __toESM(require("fast-glob"));
|
|
2847
|
+
var fs6 = __toESM(require("fs"));
|
|
2848
|
+
var path8 = __toESM(require("path"));
|
|
2777
2849
|
|
|
2778
2850
|
// src/commands/build/utilities/generateS3Key.ts
|
|
2779
2851
|
var generateS3Key_default = ({ appId, buildId, filenameSuffix }) => `${appId}/sourceArchives/${buildId}--${filenameSuffix}`;
|
|
@@ -2859,13 +2931,29 @@ async function zip_default({
|
|
|
2859
2931
|
});
|
|
2860
2932
|
const processedFiles = await Promise.all(
|
|
2861
2933
|
files.map(async (file) => {
|
|
2934
|
+
if (file.content !== void 0 && file.content !== null) {
|
|
2935
|
+
const buffer = Buffer.isBuffer(file.content) ? file.content : Buffer.from(file.content);
|
|
2936
|
+
return {
|
|
2937
|
+
...file,
|
|
2938
|
+
contentBuffer: buffer,
|
|
2939
|
+
isDirectory: false,
|
|
2940
|
+
size: buffer.length,
|
|
2941
|
+
virtual: true
|
|
2942
|
+
};
|
|
2943
|
+
}
|
|
2944
|
+
if (!file.from) {
|
|
2945
|
+
throw new Error(
|
|
2946
|
+
`Zip entry for ${file.to} must provide either a source path or in-memory content.`
|
|
2947
|
+
);
|
|
2948
|
+
}
|
|
2862
2949
|
const stats = import_fs2.default.lstatSync(file.from);
|
|
2863
2950
|
const isDirectory = stats.isDirectory();
|
|
2864
2951
|
return {
|
|
2865
2952
|
...file,
|
|
2866
2953
|
isDirectory,
|
|
2867
2954
|
stats,
|
|
2868
|
-
size: isDirectory ? await (0, import_du.default)(file.from) : stats.size
|
|
2955
|
+
size: isDirectory ? await (0, import_du.default)(file.from) : stats.size,
|
|
2956
|
+
virtual: false
|
|
2869
2957
|
};
|
|
2870
2958
|
})
|
|
2871
2959
|
);
|
|
@@ -2888,15 +2976,21 @@ Your app is larger than ${fileSizeLimit}MB. Your app is ${import_chalk.default.b
|
|
|
2888
2976
|
);
|
|
2889
2977
|
return stream;
|
|
2890
2978
|
}
|
|
2891
|
-
processedFiles.forEach((
|
|
2892
|
-
|
|
2979
|
+
processedFiles.forEach((entry) => {
|
|
2980
|
+
const { from, isDirectory, stats, to, virtual, contentBuffer, mode } = entry;
|
|
2981
|
+
if (virtual) {
|
|
2982
|
+
stream.append(contentBuffer, {
|
|
2983
|
+
name: to,
|
|
2984
|
+
mode: mode ?? 420
|
|
2985
|
+
});
|
|
2986
|
+
} else if (isDirectory) {
|
|
2893
2987
|
stream.directory(from, to);
|
|
2894
2988
|
} else if (appPkgJson && to === import_path7.default.join("app", "package.json")) {
|
|
2895
2989
|
stream.append(JSON.stringify(appPkgJson), {
|
|
2896
2990
|
name: to
|
|
2897
2991
|
});
|
|
2898
2992
|
} else {
|
|
2899
|
-
stream.file(from, { name: to, mode: stats.mode });
|
|
2993
|
+
stream.file(from, { name: to, mode: mode ?? stats.mode });
|
|
2900
2994
|
}
|
|
2901
2995
|
});
|
|
2902
2996
|
stream.finalize();
|
|
@@ -2910,6 +3004,528 @@ Your app is larger than ${fileSizeLimit}MB. Your app is ${import_chalk.default.b
|
|
|
2910
3004
|
return stream;
|
|
2911
3005
|
}
|
|
2912
3006
|
|
|
3007
|
+
// src/commands/build/utilities/workspace/index.ts
|
|
3008
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
3009
|
+
var import_fs3 = __toESM(require("fs"));
|
|
3010
|
+
var import_path8 = __toESM(require("path"));
|
|
3011
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
3012
|
+
var BUNDLED_ROOT = "bundledPackages";
|
|
3013
|
+
var DEFAULT_IGNORE_GLOBS = [
|
|
3014
|
+
"**/node_modules/**",
|
|
3015
|
+
"**/.git/**",
|
|
3016
|
+
"**/.hg/**",
|
|
3017
|
+
"**/.svn/**",
|
|
3018
|
+
"**/.DS_Store",
|
|
3019
|
+
"**/npm-debug.log",
|
|
3020
|
+
"**/yarn-error.log"
|
|
3021
|
+
];
|
|
3022
|
+
async function prepareWorkspaceBundle(input) {
|
|
3023
|
+
var _a2;
|
|
3024
|
+
const { config: config2, appPkgJson, appPath } = input;
|
|
3025
|
+
if (!((_a2 = config2.bundleWorkspacePackages) == null ? void 0 : _a2.enabled)) {
|
|
3026
|
+
return {
|
|
3027
|
+
appPackageJson: appPkgJson,
|
|
3028
|
+
entries: [],
|
|
3029
|
+
shouldBundle: false
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
const workspace = findWorkspaceDefinition(appPath, appPkgJson);
|
|
3033
|
+
if (!workspace) {
|
|
3034
|
+
throw new Error(
|
|
3035
|
+
"Bundle workspace packages is enabled but no workspace root could be found."
|
|
3036
|
+
);
|
|
3037
|
+
}
|
|
3038
|
+
if (workspace.warning) {
|
|
3039
|
+
logger_default.warn(workspace.warning);
|
|
3040
|
+
}
|
|
3041
|
+
const workspacePackages = collectWorkspacePackages(workspace);
|
|
3042
|
+
const bundledPackageNames = determineBundleClosure({
|
|
3043
|
+
appPath,
|
|
3044
|
+
appPkgJson,
|
|
3045
|
+
workspace,
|
|
3046
|
+
workspacePackages
|
|
3047
|
+
});
|
|
3048
|
+
if (!bundledPackageNames.size) {
|
|
3049
|
+
logger_default.info("No workspace packages matched bundle criteria.");
|
|
3050
|
+
return {
|
|
3051
|
+
appPackageJson: appPkgJson,
|
|
3052
|
+
entries: [],
|
|
3053
|
+
shouldBundle: false
|
|
3054
|
+
};
|
|
3055
|
+
}
|
|
3056
|
+
const bundleEntries = [];
|
|
3057
|
+
const appRewriteMap = {};
|
|
3058
|
+
const bundledPackageContexts = /* @__PURE__ */ new Map();
|
|
3059
|
+
const sortedPackageNames = Array.from(bundledPackageNames).sort();
|
|
3060
|
+
for (const packageName of sortedPackageNames) {
|
|
3061
|
+
const pkg = workspacePackages.get(packageName);
|
|
3062
|
+
if (!pkg) {
|
|
3063
|
+
throw new Error(
|
|
3064
|
+
`Workspace package "${packageName}" referenced for bundling but not found in workspace map.`
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
const bundlePath = getBundlePath(packageName);
|
|
3068
|
+
bundledPackageContexts.set(packageName, { bundlePath, packageName });
|
|
3069
|
+
appRewriteMap[packageName] = `file:../${import_path8.default.posix.join(
|
|
3070
|
+
BUNDLED_ROOT,
|
|
3071
|
+
bundlePath
|
|
3072
|
+
)}`;
|
|
3073
|
+
const packageEntries = await buildPackageEntries({
|
|
3074
|
+
bundlePath,
|
|
3075
|
+
workspacePackage: pkg,
|
|
3076
|
+
bundledNames: bundledPackageNames,
|
|
3077
|
+
contexts: bundledPackageContexts
|
|
3078
|
+
});
|
|
3079
|
+
bundleEntries.push(...packageEntries.files);
|
|
3080
|
+
bundleEntries.push(packageEntries.packageJsonEntry);
|
|
3081
|
+
}
|
|
3082
|
+
const rewrittenAppPkgJson = applyRewriteMap(appPkgJson, appRewriteMap);
|
|
3083
|
+
logger_default.info(
|
|
3084
|
+
`Bundling ${sortedPackageNames.length} workspace package(s) from ${workspace.type} workspace at ${workspace.rootDir}`
|
|
3085
|
+
);
|
|
3086
|
+
logger_default.info(`Bundled packages: ${sortedPackageNames.join(", ")}`);
|
|
3087
|
+
return {
|
|
3088
|
+
appPackageJson: rewrittenAppPkgJson,
|
|
3089
|
+
entries: bundleEntries,
|
|
3090
|
+
shouldBundle: true
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
function findWorkspaceDefinition(appPath, appPkgJson) {
|
|
3094
|
+
const appDir = import_path8.default.resolve(appPath);
|
|
3095
|
+
let currentDir = appDir;
|
|
3096
|
+
let previousDir = "";
|
|
3097
|
+
const pnpmPreference = detectPnpmPreference(appPkgJson);
|
|
3098
|
+
while (currentDir !== previousDir) {
|
|
3099
|
+
const pnpmFile = import_path8.default.join(currentDir, "pnpm-workspace.yaml");
|
|
3100
|
+
const packageJsonPath = import_path8.default.join(currentDir, "package.json");
|
|
3101
|
+
const hasPnpm = import_fs3.default.existsSync(pnpmFile);
|
|
3102
|
+
const packageJson2 = readPackageJsonIfExists(packageJsonPath);
|
|
3103
|
+
const npmWorkspaces = getNpmWorkspaces(packageJson2);
|
|
3104
|
+
if (hasPnpm || npmWorkspaces.length) {
|
|
3105
|
+
const pnpmDefinition = hasPnpm ? createPnpmDefinition({ pnpmFile, rootDir: currentDir }) : void 0;
|
|
3106
|
+
const npmDefinition = npmWorkspaces.length ? createNpmDefinition({ globs: npmWorkspaces, rootDir: currentDir }) : void 0;
|
|
3107
|
+
const chosen = chooseWorkspaceDefinition({
|
|
3108
|
+
pnpmPreference,
|
|
3109
|
+
pnpmDefinition,
|
|
3110
|
+
npmDefinition
|
|
3111
|
+
});
|
|
3112
|
+
if (chosen) {
|
|
3113
|
+
const includesApp = workspaceIncludesPath({
|
|
3114
|
+
appDir,
|
|
3115
|
+
globs: chosen.globs,
|
|
3116
|
+
rootDir: chosen.rootDir
|
|
3117
|
+
});
|
|
3118
|
+
if (includesApp) {
|
|
3119
|
+
return chosen;
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
previousDir = currentDir;
|
|
3124
|
+
currentDir = import_path8.default.dirname(currentDir);
|
|
3125
|
+
}
|
|
3126
|
+
return void 0;
|
|
3127
|
+
}
|
|
3128
|
+
function detectPnpmPreference(appPkgJson) {
|
|
3129
|
+
const pkgManager = appPkgJson.packageManager;
|
|
3130
|
+
if (typeof pkgManager !== "string") {
|
|
3131
|
+
return false;
|
|
3132
|
+
}
|
|
3133
|
+
return pkgManager.startsWith("pnpm@");
|
|
3134
|
+
}
|
|
3135
|
+
function readPackageJsonIfExists(filePath) {
|
|
3136
|
+
if (!import_fs3.default.existsSync(filePath)) {
|
|
3137
|
+
return void 0;
|
|
3138
|
+
}
|
|
3139
|
+
try {
|
|
3140
|
+
return JSON.parse(import_fs3.default.readFileSync(filePath, "utf8"));
|
|
3141
|
+
} catch (error) {
|
|
3142
|
+
throw new Error(`Unable to parse package.json at ${filePath}: ${error}`);
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
function getNpmWorkspaces(packageJson2) {
|
|
3146
|
+
if (!packageJson2) {
|
|
3147
|
+
return [];
|
|
3148
|
+
}
|
|
3149
|
+
const { workspaces } = packageJson2;
|
|
3150
|
+
if (!workspaces) {
|
|
3151
|
+
return [];
|
|
3152
|
+
}
|
|
3153
|
+
if (Array.isArray(workspaces)) {
|
|
3154
|
+
return workspaces.filter(
|
|
3155
|
+
(value) => typeof value === "string"
|
|
3156
|
+
);
|
|
3157
|
+
}
|
|
3158
|
+
if (typeof workspaces === "object" && Array.isArray(workspaces.packages)) {
|
|
3159
|
+
return workspaces.packages.filter(
|
|
3160
|
+
(value) => typeof value === "string"
|
|
3161
|
+
);
|
|
3162
|
+
}
|
|
3163
|
+
return [];
|
|
3164
|
+
}
|
|
3165
|
+
function createPnpmDefinition({
|
|
3166
|
+
pnpmFile,
|
|
3167
|
+
rootDir
|
|
3168
|
+
}) {
|
|
3169
|
+
const packages = parsePnpmWorkspaceFile(pnpmFile);
|
|
3170
|
+
if (!packages.length) {
|
|
3171
|
+
throw new Error(
|
|
3172
|
+
`pnpm workspace file at ${pnpmFile} does not define any packages.`
|
|
3173
|
+
);
|
|
3174
|
+
}
|
|
3175
|
+
return {
|
|
3176
|
+
globs: packages,
|
|
3177
|
+
rootDir,
|
|
3178
|
+
realRootDir: import_fs3.default.realpathSync(rootDir),
|
|
3179
|
+
type: "pnpm"
|
|
3180
|
+
};
|
|
3181
|
+
}
|
|
3182
|
+
function createNpmDefinition({
|
|
3183
|
+
globs,
|
|
3184
|
+
rootDir
|
|
3185
|
+
}) {
|
|
3186
|
+
return {
|
|
3187
|
+
globs,
|
|
3188
|
+
rootDir,
|
|
3189
|
+
realRootDir: import_fs3.default.realpathSync(rootDir),
|
|
3190
|
+
type: "npm"
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
function chooseWorkspaceDefinition({
|
|
3194
|
+
pnpmPreference,
|
|
3195
|
+
pnpmDefinition,
|
|
3196
|
+
npmDefinition
|
|
3197
|
+
}) {
|
|
3198
|
+
if (pnpmDefinition && npmDefinition) {
|
|
3199
|
+
const warning = "Both pnpm-workspace.yaml and package.json workspaces detected; defaulting to pnpm.";
|
|
3200
|
+
if (pnpmPreference) {
|
|
3201
|
+
return pnpmDefinition;
|
|
3202
|
+
}
|
|
3203
|
+
return { ...pnpmDefinition, warning };
|
|
3204
|
+
}
|
|
3205
|
+
return pnpmDefinition || npmDefinition;
|
|
3206
|
+
}
|
|
3207
|
+
function parsePnpmWorkspaceFile(filePath) {
|
|
3208
|
+
const content = import_fs3.default.readFileSync(filePath, "utf8");
|
|
3209
|
+
const parsed = import_js_yaml.default.load(content);
|
|
3210
|
+
let packagesField;
|
|
3211
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
3212
|
+
packagesField = parsed.packages;
|
|
3213
|
+
} else {
|
|
3214
|
+
packagesField = parsed;
|
|
3215
|
+
}
|
|
3216
|
+
if (!Array.isArray(packagesField)) {
|
|
3217
|
+
throw new Error(
|
|
3218
|
+
`pnpm workspace file at ${filePath} does not define any packages.`
|
|
3219
|
+
);
|
|
3220
|
+
}
|
|
3221
|
+
const packages = packagesField.map((value) => typeof value === "string" ? value.trim() : "").filter((value) => Boolean(value));
|
|
3222
|
+
if (!packages.length) {
|
|
3223
|
+
throw new Error(
|
|
3224
|
+
`pnpm workspace file at ${filePath} does not define any packages.`
|
|
3225
|
+
);
|
|
3226
|
+
}
|
|
3227
|
+
return packages;
|
|
3228
|
+
}
|
|
3229
|
+
function workspaceIncludesPath({
|
|
3230
|
+
appDir,
|
|
3231
|
+
globs,
|
|
3232
|
+
rootDir
|
|
3233
|
+
}) {
|
|
3234
|
+
const target = import_path8.default.resolve(appDir);
|
|
3235
|
+
const matches = import_fast_glob.default.sync(globs, {
|
|
3236
|
+
absolute: true,
|
|
3237
|
+
cwd: rootDir,
|
|
3238
|
+
onlyDirectories: true,
|
|
3239
|
+
followSymbolicLinks: false,
|
|
3240
|
+
ignore: ["**/node_modules/**"]
|
|
3241
|
+
});
|
|
3242
|
+
return matches.some((dir) => import_path8.default.resolve(dir) === target);
|
|
3243
|
+
}
|
|
3244
|
+
function collectWorkspacePackages(definition) {
|
|
3245
|
+
const { globs, rootDir } = definition;
|
|
3246
|
+
const directories = import_fast_glob.default.sync(globs, {
|
|
3247
|
+
absolute: true,
|
|
3248
|
+
cwd: rootDir,
|
|
3249
|
+
onlyDirectories: true,
|
|
3250
|
+
followSymbolicLinks: false,
|
|
3251
|
+
ignore: ["**/node_modules/**"]
|
|
3252
|
+
});
|
|
3253
|
+
const packages = /* @__PURE__ */ new Map();
|
|
3254
|
+
for (const dir of directories) {
|
|
3255
|
+
const packageJsonPath = import_path8.default.join(dir, "package.json");
|
|
3256
|
+
if (!import_fs3.default.existsSync(packageJsonPath)) {
|
|
3257
|
+
continue;
|
|
3258
|
+
}
|
|
3259
|
+
const manifest = readPackageJsonIfExists(packageJsonPath);
|
|
3260
|
+
if (!manifest || !manifest.name) {
|
|
3261
|
+
continue;
|
|
3262
|
+
}
|
|
3263
|
+
const name = manifest.name;
|
|
3264
|
+
if (packages.has(name)) {
|
|
3265
|
+
const existing = packages.get(name);
|
|
3266
|
+
throw new Error(
|
|
3267
|
+
`Duplicate workspace package name "${name}" found at ${existing == null ? void 0 : existing.dir} and ${dir}`
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3270
|
+
const absoluteDir = import_path8.default.resolve(dir);
|
|
3271
|
+
const pkg = {
|
|
3272
|
+
dir: absoluteDir,
|
|
3273
|
+
manifest,
|
|
3274
|
+
name,
|
|
3275
|
+
realDir: import_fs3.default.realpathSync(absoluteDir)
|
|
3276
|
+
};
|
|
3277
|
+
packages.set(name, pkg);
|
|
3278
|
+
}
|
|
3279
|
+
return packages;
|
|
3280
|
+
}
|
|
3281
|
+
function determineBundleClosure({
|
|
3282
|
+
appPath,
|
|
3283
|
+
appPkgJson,
|
|
3284
|
+
workspace,
|
|
3285
|
+
workspacePackages
|
|
3286
|
+
}) {
|
|
3287
|
+
const bundled = /* @__PURE__ */ new Set();
|
|
3288
|
+
const queue = [];
|
|
3289
|
+
collectDependencyReferences({
|
|
3290
|
+
manifest: appPkgJson,
|
|
3291
|
+
packageDir: appPath,
|
|
3292
|
+
queue,
|
|
3293
|
+
workspace,
|
|
3294
|
+
workspacePackages,
|
|
3295
|
+
sourceName: "app"
|
|
3296
|
+
});
|
|
3297
|
+
while (queue.length) {
|
|
3298
|
+
const ref = queue.shift();
|
|
3299
|
+
if (!ref) {
|
|
3300
|
+
continue;
|
|
3301
|
+
}
|
|
3302
|
+
const targetPackage = workspacePackages.get(ref.name);
|
|
3303
|
+
if (!targetPackage) {
|
|
3304
|
+
throw new Error(
|
|
3305
|
+
`Dependency "${ref.name}" referenced via ${ref.section} is not part of the workspace.`
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3308
|
+
if (bundled.has(targetPackage.name)) {
|
|
3309
|
+
continue;
|
|
3310
|
+
}
|
|
3311
|
+
bundled.add(targetPackage.name);
|
|
3312
|
+
collectDependencyReferences({
|
|
3313
|
+
manifest: targetPackage.manifest,
|
|
3314
|
+
packageDir: targetPackage.dir,
|
|
3315
|
+
queue,
|
|
3316
|
+
workspace,
|
|
3317
|
+
workspacePackages,
|
|
3318
|
+
sourceName: targetPackage.name
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
return bundled;
|
|
3322
|
+
}
|
|
3323
|
+
function collectDependencyReferences({
|
|
3324
|
+
manifest,
|
|
3325
|
+
packageDir,
|
|
3326
|
+
queue,
|
|
3327
|
+
workspace,
|
|
3328
|
+
workspacePackages,
|
|
3329
|
+
sourceName
|
|
3330
|
+
}) {
|
|
3331
|
+
const sections = [
|
|
3332
|
+
"dependencies",
|
|
3333
|
+
"optionalDependencies",
|
|
3334
|
+
"devDependencies"
|
|
3335
|
+
];
|
|
3336
|
+
for (const section of sections) {
|
|
3337
|
+
const deps = manifest[section];
|
|
3338
|
+
if (!deps) continue;
|
|
3339
|
+
for (const [depName, spec] of Object.entries(deps)) {
|
|
3340
|
+
if (typeof spec !== "string") continue;
|
|
3341
|
+
const target = resolveWorkspaceTarget({
|
|
3342
|
+
depName,
|
|
3343
|
+
packageDir,
|
|
3344
|
+
spec,
|
|
3345
|
+
workspace,
|
|
3346
|
+
workspacePackages,
|
|
3347
|
+
sourceName
|
|
3348
|
+
});
|
|
3349
|
+
if (target) {
|
|
3350
|
+
queue.push({ name: target, spec, section });
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
function resolveWorkspaceTarget({
|
|
3356
|
+
depName,
|
|
3357
|
+
packageDir,
|
|
3358
|
+
spec,
|
|
3359
|
+
workspace,
|
|
3360
|
+
workspacePackages,
|
|
3361
|
+
sourceName
|
|
3362
|
+
}) {
|
|
3363
|
+
if (spec.startsWith("workspace:")) {
|
|
3364
|
+
if (!workspacePackages.has(depName)) {
|
|
3365
|
+
throw new Error(
|
|
3366
|
+
`Workspace dependency "${depName}" referenced by ${sourceName} is not declared in workspace globs.`
|
|
3367
|
+
);
|
|
3368
|
+
}
|
|
3369
|
+
return depName;
|
|
3370
|
+
}
|
|
3371
|
+
if (spec.startsWith("file:")) {
|
|
3372
|
+
const targetPath = spec.slice("file:".length);
|
|
3373
|
+
const resolved = import_path8.default.resolve(packageDir, targetPath);
|
|
3374
|
+
const targetRealPath = import_fs3.default.realpathSync(resolved);
|
|
3375
|
+
const relativeToRoot = import_path8.default.relative(workspace.realRootDir, targetRealPath);
|
|
3376
|
+
if (relativeToRoot.startsWith("..") || import_path8.default.isAbsolute(relativeToRoot)) {
|
|
3377
|
+
throw new Error(
|
|
3378
|
+
`Dependency "${depName}" from ${sourceName} resolves outside of workspace root via spec ${spec}.`
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3381
|
+
for (const pkg of workspacePackages.values()) {
|
|
3382
|
+
if (pkg.realDir === targetRealPath) {
|
|
3383
|
+
return pkg.name;
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
throw new Error(
|
|
3387
|
+
`Dependency "${depName}" from ${sourceName} points to ${resolved}, which is not a known workspace package.`
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
3390
|
+
return void 0;
|
|
3391
|
+
}
|
|
3392
|
+
function getBundlePath(packageName) {
|
|
3393
|
+
if (packageName.startsWith("@")) {
|
|
3394
|
+
const [scope, ...rest] = packageName.split("/");
|
|
3395
|
+
return [scope, rest.join("/")].filter(Boolean).join("/");
|
|
3396
|
+
}
|
|
3397
|
+
return packageName;
|
|
3398
|
+
}
|
|
3399
|
+
function applyRewriteMap(manifest, rewriteMap) {
|
|
3400
|
+
const clone = JSON.parse(JSON.stringify(manifest));
|
|
3401
|
+
const sections = [
|
|
3402
|
+
"dependencies",
|
|
3403
|
+
"optionalDependencies",
|
|
3404
|
+
"devDependencies"
|
|
3405
|
+
];
|
|
3406
|
+
for (const section of sections) {
|
|
3407
|
+
const sectionDeps = clone[section];
|
|
3408
|
+
if (!sectionDeps) continue;
|
|
3409
|
+
for (const [depName, rewrite] of Object.entries(rewriteMap)) {
|
|
3410
|
+
if (sectionDeps[depName]) {
|
|
3411
|
+
sectionDeps[depName] = rewrite;
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
return clone;
|
|
3416
|
+
}
|
|
3417
|
+
async function buildPackageEntries({
|
|
3418
|
+
bundlePath,
|
|
3419
|
+
workspacePackage,
|
|
3420
|
+
bundledNames,
|
|
3421
|
+
contexts
|
|
3422
|
+
}) {
|
|
3423
|
+
const packageDir = workspacePackage.dir;
|
|
3424
|
+
const manifest = workspacePackage.manifest;
|
|
3425
|
+
const filesToInclude = await gatherPackageFiles({ packageDir, manifest });
|
|
3426
|
+
const files = filesToInclude.map((absolutePath) => {
|
|
3427
|
+
const relative3 = import_path8.default.relative(packageDir, absolutePath);
|
|
3428
|
+
const posixRelative = toPosix(import_path8.default.join(bundlePath, relative3));
|
|
3429
|
+
return {
|
|
3430
|
+
from: absolutePath,
|
|
3431
|
+
to: import_path8.default.posix.join(BUNDLED_ROOT, posixRelative)
|
|
3432
|
+
};
|
|
3433
|
+
});
|
|
3434
|
+
const rewrites = buildRewriteMapForPackage({
|
|
3435
|
+
bundlePath,
|
|
3436
|
+
manifest,
|
|
3437
|
+
bundledNames,
|
|
3438
|
+
contexts
|
|
3439
|
+
});
|
|
3440
|
+
const packageJsonEntry = {
|
|
3441
|
+
content: Buffer.from(
|
|
3442
|
+
`${JSON.stringify(applyRewriteMap(manifest, rewrites), null, 2)}
|
|
3443
|
+
`
|
|
3444
|
+
),
|
|
3445
|
+
to: import_path8.default.posix.join(BUNDLED_ROOT, bundlePath, "package.json")
|
|
3446
|
+
};
|
|
3447
|
+
return { files, packageJsonEntry };
|
|
3448
|
+
}
|
|
3449
|
+
async function gatherPackageFiles({
|
|
3450
|
+
packageDir,
|
|
3451
|
+
manifest
|
|
3452
|
+
}) {
|
|
3453
|
+
const declaredPatterns = Array.isArray(manifest.files) ? manifest.files : ["**/*"];
|
|
3454
|
+
const normalizedPatterns = declaredPatterns.flatMap((pattern) => {
|
|
3455
|
+
if (pattern.includes("*")) {
|
|
3456
|
+
return [pattern];
|
|
3457
|
+
}
|
|
3458
|
+
const absoluteCandidate = import_path8.default.join(packageDir, pattern);
|
|
3459
|
+
try {
|
|
3460
|
+
const stats = import_fs3.default.statSync(absoluteCandidate);
|
|
3461
|
+
if (stats.isDirectory()) {
|
|
3462
|
+
const posixPattern = pattern.replace(/\\/g, "/");
|
|
3463
|
+
return [pattern, `${posixPattern}/**/*`];
|
|
3464
|
+
}
|
|
3465
|
+
} catch (error) {
|
|
3466
|
+
}
|
|
3467
|
+
return [pattern];
|
|
3468
|
+
});
|
|
3469
|
+
const matchedFiles = await (0, import_fast_glob.default)(normalizedPatterns, {
|
|
3470
|
+
absolute: true,
|
|
3471
|
+
cwd: packageDir,
|
|
3472
|
+
dot: true,
|
|
3473
|
+
onlyFiles: true,
|
|
3474
|
+
followSymbolicLinks: false,
|
|
3475
|
+
ignore: DEFAULT_IGNORE_GLOBS
|
|
3476
|
+
});
|
|
3477
|
+
const extras = [
|
|
3478
|
+
"README",
|
|
3479
|
+
"README.md",
|
|
3480
|
+
"README.txt",
|
|
3481
|
+
"LICENSE",
|
|
3482
|
+
"LICENCE",
|
|
3483
|
+
"NOTICE",
|
|
3484
|
+
"CHANGELOG",
|
|
3485
|
+
"CHANGELOG.md"
|
|
3486
|
+
];
|
|
3487
|
+
for (const extra of extras) {
|
|
3488
|
+
const extraPath = import_path8.default.join(packageDir, extra);
|
|
3489
|
+
if (import_fs3.default.existsSync(extraPath) && import_fs3.default.statSync(extraPath).isFile()) {
|
|
3490
|
+
matchedFiles.push(extraPath);
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
const uniqueFiles = Array.from(new Set(matchedFiles));
|
|
3494
|
+
return uniqueFiles.filter((filePath) => !filePath.endsWith("package.json"));
|
|
3495
|
+
}
|
|
3496
|
+
function buildRewriteMapForPackage({
|
|
3497
|
+
bundlePath,
|
|
3498
|
+
manifest,
|
|
3499
|
+
bundledNames,
|
|
3500
|
+
contexts
|
|
3501
|
+
}) {
|
|
3502
|
+
var _a2;
|
|
3503
|
+
const rewriteMap = {};
|
|
3504
|
+
const sections = [
|
|
3505
|
+
"dependencies",
|
|
3506
|
+
"optionalDependencies",
|
|
3507
|
+
"devDependencies"
|
|
3508
|
+
];
|
|
3509
|
+
for (const section of sections) {
|
|
3510
|
+
const deps = manifest[section];
|
|
3511
|
+
if (!deps) continue;
|
|
3512
|
+
for (const [depName, spec] of Object.entries(deps)) {
|
|
3513
|
+
if (typeof spec !== "string") continue;
|
|
3514
|
+
if (bundledNames.has(depName)) {
|
|
3515
|
+
const targetBundlePath = ((_a2 = contexts.get(depName)) == null ? void 0 : _a2.bundlePath) ?? getBundlePath(depName);
|
|
3516
|
+
const fromPath = import_path8.default.posix.join(BUNDLED_ROOT, bundlePath);
|
|
3517
|
+
const toPath = import_path8.default.posix.join(BUNDLED_ROOT, targetBundlePath);
|
|
3518
|
+
const relative3 = import_path8.default.posix.relative(fromPath, toPath) || ".";
|
|
3519
|
+
rewriteMap[depName] = `file:${relative3}`;
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
return rewriteMap;
|
|
3524
|
+
}
|
|
3525
|
+
function toPosix(targetPath) {
|
|
3526
|
+
return targetPath.split(import_path8.default.sep).join(import_path8.default.posix.sep);
|
|
3527
|
+
}
|
|
3528
|
+
|
|
2913
3529
|
// src/commands/build/utilities/uploadApplicationSource.ts
|
|
2914
3530
|
var getAppFiles = async (globsInput, appPath, appPkgJson) => {
|
|
2915
3531
|
const globs = [
|
|
@@ -2923,11 +3539,11 @@ var getAppFiles = async (globsInput, appPath, appPkgJson) => {
|
|
|
2923
3539
|
if (globsInput && globsInput.length) {
|
|
2924
3540
|
globs.push(
|
|
2925
3541
|
...globsInput,
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
3542
|
+
path8.join(appPath, "package.json"),
|
|
3543
|
+
path8.join(appPath, "package-lock.json"),
|
|
3544
|
+
path8.join(appPath, "yarn.lock"),
|
|
3545
|
+
path8.join(appPath, "pnpm-lock.yaml"),
|
|
3546
|
+
path8.join(appPath, "shrinkwrap.yaml")
|
|
2931
3547
|
);
|
|
2932
3548
|
} else {
|
|
2933
3549
|
globs.push("**");
|
|
@@ -2938,14 +3554,14 @@ var getAppFiles = async (globsInput, appPath, appPkgJson) => {
|
|
|
2938
3554
|
"todesktop:afterPack"
|
|
2939
3555
|
]) {
|
|
2940
3556
|
if (appPkgJson.scripts && appPkgJson.scripts[hookName]) {
|
|
2941
|
-
globs.push(
|
|
3557
|
+
globs.push(path8.join(appPath, appPkgJson.scripts[hookName]));
|
|
2942
3558
|
}
|
|
2943
3559
|
}
|
|
2944
3560
|
const normalizedGlobs = globs.map((glob) => {
|
|
2945
|
-
const globToUse =
|
|
3561
|
+
const globToUse = path8.isAbsolute(glob) ? path8.relative(appPath, glob) : glob;
|
|
2946
3562
|
return globToUse.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
2947
3563
|
}).filter((glob) => !glob.startsWith("..") && !glob.startsWith("!.."));
|
|
2948
|
-
let absolutePaths = await (0,
|
|
3564
|
+
let absolutePaths = await (0, import_fast_glob2.default)(normalizedGlobs, {
|
|
2949
3565
|
absolute: true,
|
|
2950
3566
|
cwd: appPath,
|
|
2951
3567
|
dot: true,
|
|
@@ -2957,7 +3573,7 @@ var getAppFiles = async (globsInput, appPath, appPkgJson) => {
|
|
|
2957
3573
|
});
|
|
2958
3574
|
if (process.platform === "win32") {
|
|
2959
3575
|
absolutePaths = absolutePaths.map(
|
|
2960
|
-
(absolutePath) => absolutePath.replace(/\//g,
|
|
3576
|
+
(absolutePath) => absolutePath.replace(/\//g, path8.sep)
|
|
2961
3577
|
);
|
|
2962
3578
|
}
|
|
2963
3579
|
if (!absolutePaths || !absolutePaths.length) {
|
|
@@ -2971,21 +3587,21 @@ var getAppFiles = async (globsInput, appPath, appPkgJson) => {
|
|
|
2971
3587
|
} else {
|
|
2972
3588
|
let mainFilePath = appPath;
|
|
2973
3589
|
if (appPkgJson.main) {
|
|
2974
|
-
mainFilePath =
|
|
3590
|
+
mainFilePath = path8.join(mainFilePath, appPkgJson.main);
|
|
2975
3591
|
}
|
|
2976
|
-
if (
|
|
2977
|
-
mainFilePath =
|
|
3592
|
+
if (fs6.statSync(mainFilePath).isDirectory()) {
|
|
3593
|
+
mainFilePath = path8.join(mainFilePath, "index.js");
|
|
2978
3594
|
}
|
|
2979
3595
|
if (!absolutePaths.includes(mainFilePath)) {
|
|
2980
3596
|
throw new Error(
|
|
2981
|
-
`The "main" file specified in your package.json (${appPkgJson.main ?
|
|
3597
|
+
`The "main" file specified in your package.json (${appPkgJson.main ? path8.relative(appPath, mainFilePath) : "defaults to index.js"}) is not set to be uploaded to our servers. This is likely due to how you have configured the \`appFiles\` option. Learn more at https://www.npmjs.com/package/@todesktop/cli#appfiles----optional-array-of-glob-patterns. If this is not the case, please contact us.`
|
|
2982
3598
|
);
|
|
2983
3599
|
}
|
|
2984
3600
|
}
|
|
2985
3601
|
return absolutePaths.map((absolutePath) => {
|
|
2986
3602
|
return {
|
|
2987
3603
|
from: absolutePath,
|
|
2988
|
-
to:
|
|
3604
|
+
to: path8.join("app", path8.relative(appPath, absolutePath))
|
|
2989
3605
|
};
|
|
2990
3606
|
});
|
|
2991
3607
|
};
|
|
@@ -2996,7 +3612,7 @@ async function uploadApplicationSource({
|
|
|
2996
3612
|
config: config2,
|
|
2997
3613
|
onProgress
|
|
2998
3614
|
}) {
|
|
2999
|
-
var
|
|
3615
|
+
var _a2;
|
|
3000
3616
|
logger_default.debug(
|
|
3001
3617
|
{
|
|
3002
3618
|
scrub: {
|
|
@@ -3010,11 +3626,29 @@ async function uploadApplicationSource({
|
|
|
3010
3626
|
"uploadApplicationSource"
|
|
3011
3627
|
);
|
|
3012
3628
|
let totalBytes = 0;
|
|
3629
|
+
let effectiveAppPkgJson = appPkgJson;
|
|
3630
|
+
let workspaceEntries = [];
|
|
3631
|
+
try {
|
|
3632
|
+
const workspaceBundle = await prepareWorkspaceBundle({
|
|
3633
|
+
appPath: config2.appPath,
|
|
3634
|
+
appPkgJson,
|
|
3635
|
+
config: config2
|
|
3636
|
+
});
|
|
3637
|
+
effectiveAppPkgJson = workspaceBundle.appPackageJson;
|
|
3638
|
+
workspaceEntries = workspaceBundle.entries;
|
|
3639
|
+
} catch (error) {
|
|
3640
|
+
logger_default.error({ err: error }, "Failed to prepare workspace bundle");
|
|
3641
|
+
throw error;
|
|
3642
|
+
}
|
|
3013
3643
|
const files = [
|
|
3014
3644
|
/*
|
|
3015
3645
|
App files (stored in app/ in the ZIP)
|
|
3016
3646
|
*/
|
|
3017
|
-
...await getAppFiles(
|
|
3647
|
+
...await getAppFiles(
|
|
3648
|
+
config2.appFiles,
|
|
3649
|
+
config2.appPath,
|
|
3650
|
+
effectiveAppPkgJson
|
|
3651
|
+
),
|
|
3018
3652
|
/*
|
|
3019
3653
|
Optional extra content files (stored in extraContentFiles/ in the ZIP). Their
|
|
3020
3654
|
paths within is the their relative path from the project root so
|
|
@@ -3025,7 +3659,7 @@ async function uploadApplicationSource({
|
|
|
3025
3659
|
...(config2.extraContentFiles || []).map(({ from, to = "." }) => {
|
|
3026
3660
|
return {
|
|
3027
3661
|
from,
|
|
3028
|
-
to:
|
|
3662
|
+
to: path8.join("extraContentFiles", to, path8.basename(from))
|
|
3029
3663
|
};
|
|
3030
3664
|
}),
|
|
3031
3665
|
/*
|
|
@@ -3035,7 +3669,7 @@ async function uploadApplicationSource({
|
|
|
3035
3669
|
...(config2.extraResources || []).map(({ from, to = "." }) => {
|
|
3036
3670
|
return {
|
|
3037
3671
|
from,
|
|
3038
|
-
to:
|
|
3672
|
+
to: path8.join("extraResources", to, path8.basename(from))
|
|
3039
3673
|
};
|
|
3040
3674
|
}),
|
|
3041
3675
|
/*
|
|
@@ -3043,16 +3677,16 @@ async function uploadApplicationSource({
|
|
|
3043
3677
|
*/
|
|
3044
3678
|
{
|
|
3045
3679
|
from: config2.icon,
|
|
3046
|
-
to:
|
|
3680
|
+
to: path8.join("icons", "appIcon" + path8.extname(config2.icon))
|
|
3047
3681
|
}
|
|
3048
3682
|
];
|
|
3049
3683
|
if (config2.linux) {
|
|
3050
3684
|
if (config2.linux.icon) {
|
|
3051
3685
|
files.push({
|
|
3052
3686
|
from: config2.linux.icon,
|
|
3053
|
-
to:
|
|
3687
|
+
to: path8.join(
|
|
3054
3688
|
"icons",
|
|
3055
|
-
"appIcon-linux" +
|
|
3689
|
+
"appIcon-linux" + path8.extname(config2.linux.icon)
|
|
3056
3690
|
)
|
|
3057
3691
|
});
|
|
3058
3692
|
}
|
|
@@ -3061,10 +3695,10 @@ async function uploadApplicationSource({
|
|
|
3061
3695
|
const possibleIcons = [];
|
|
3062
3696
|
for (const fa of config2.fileAssociations) {
|
|
3063
3697
|
if (fa.icon) {
|
|
3064
|
-
const icon =
|
|
3698
|
+
const icon = path8.parse(fa.icon);
|
|
3065
3699
|
possibleIcons.push(
|
|
3066
|
-
{ ext: fa.ext, icon:
|
|
3067
|
-
{ ext: fa.ext, icon:
|
|
3700
|
+
{ ext: fa.ext, icon: path8.join(icon.dir, icon.name) + ".ico" },
|
|
3701
|
+
{ ext: fa.ext, icon: path8.join(icon.dir, icon.name) + ".icns" }
|
|
3068
3702
|
);
|
|
3069
3703
|
}
|
|
3070
3704
|
}
|
|
@@ -3073,7 +3707,7 @@ async function uploadApplicationSource({
|
|
|
3073
3707
|
if (await exists(icon)) {
|
|
3074
3708
|
files.push({
|
|
3075
3709
|
from: icon,
|
|
3076
|
-
to:
|
|
3710
|
+
to: path8.join("icons", "association-" + ext + path8.extname(icon))
|
|
3077
3711
|
});
|
|
3078
3712
|
}
|
|
3079
3713
|
})
|
|
@@ -3083,25 +3717,25 @@ async function uploadApplicationSource({
|
|
|
3083
3717
|
if (config2.mac.entitlements) {
|
|
3084
3718
|
files.push({
|
|
3085
3719
|
from: config2.mac.entitlements,
|
|
3086
|
-
to:
|
|
3720
|
+
to: path8.join("other", "mac", "entitlements.mac.plist")
|
|
3087
3721
|
});
|
|
3088
3722
|
}
|
|
3089
3723
|
if (config2.mac.entitlementsInherit) {
|
|
3090
3724
|
files.push({
|
|
3091
3725
|
from: config2.mac.entitlementsInherit,
|
|
3092
|
-
to:
|
|
3726
|
+
to: path8.join("other", "mac", "entitlementsInherit.mac.plist")
|
|
3093
3727
|
});
|
|
3094
3728
|
}
|
|
3095
3729
|
if (config2.mac.icon) {
|
|
3096
3730
|
files.push({
|
|
3097
3731
|
from: config2.mac.icon,
|
|
3098
|
-
to:
|
|
3732
|
+
to: path8.join("icons", "appIcon-mac" + path8.extname(config2.mac.icon))
|
|
3099
3733
|
});
|
|
3100
3734
|
}
|
|
3101
3735
|
if (config2.mac.requirements) {
|
|
3102
3736
|
files.push({
|
|
3103
3737
|
from: config2.mac.requirements,
|
|
3104
|
-
to:
|
|
3738
|
+
to: path8.join("other", "mac", "requirements.txt")
|
|
3105
3739
|
});
|
|
3106
3740
|
}
|
|
3107
3741
|
}
|
|
@@ -3109,19 +3743,19 @@ async function uploadApplicationSource({
|
|
|
3109
3743
|
if (config2.mas.entitlements) {
|
|
3110
3744
|
files.push({
|
|
3111
3745
|
from: config2.mas.entitlements,
|
|
3112
|
-
to:
|
|
3746
|
+
to: path8.join("other", "mac", "entitlements.mas.plist")
|
|
3113
3747
|
});
|
|
3114
3748
|
}
|
|
3115
3749
|
if (config2.mas.entitlementsInherit) {
|
|
3116
3750
|
files.push({
|
|
3117
3751
|
from: config2.mas.entitlementsInherit,
|
|
3118
|
-
to:
|
|
3752
|
+
to: path8.join("other", "mac", "entitlementsInherit.mas.plist")
|
|
3119
3753
|
});
|
|
3120
3754
|
}
|
|
3121
3755
|
if (config2.mas.provisioningProfile) {
|
|
3122
3756
|
files.push({
|
|
3123
3757
|
from: config2.mas.provisioningProfile,
|
|
3124
|
-
to:
|
|
3758
|
+
to: path8.join("other", "mac", "mas.provisionprofile")
|
|
3125
3759
|
});
|
|
3126
3760
|
}
|
|
3127
3761
|
}
|
|
@@ -3129,7 +3763,7 @@ async function uploadApplicationSource({
|
|
|
3129
3763
|
if (config2.dmg.background) {
|
|
3130
3764
|
files.push({
|
|
3131
3765
|
from: config2.dmg.background,
|
|
3132
|
-
to:
|
|
3766
|
+
to: path8.join("other", "mac", "dmg-background.tiff")
|
|
3133
3767
|
});
|
|
3134
3768
|
}
|
|
3135
3769
|
}
|
|
@@ -3137,19 +3771,22 @@ async function uploadApplicationSource({
|
|
|
3137
3771
|
if (config2.windows.icon) {
|
|
3138
3772
|
files.push({
|
|
3139
3773
|
from: config2.windows.icon,
|
|
3140
|
-
to:
|
|
3774
|
+
to: path8.join(
|
|
3141
3775
|
"icons",
|
|
3142
|
-
"appIcon-windows" +
|
|
3776
|
+
"appIcon-windows" + path8.extname(config2.windows.icon)
|
|
3143
3777
|
)
|
|
3144
3778
|
});
|
|
3145
3779
|
}
|
|
3146
3780
|
if (config2.windows.nsisInclude) {
|
|
3147
3781
|
files.push({
|
|
3148
3782
|
from: config2.windows.nsisInclude,
|
|
3149
|
-
to:
|
|
3783
|
+
to: path8.join("other", "installer.nsh")
|
|
3150
3784
|
});
|
|
3151
3785
|
}
|
|
3152
3786
|
}
|
|
3787
|
+
if (workspaceEntries.length) {
|
|
3788
|
+
files.push(...workspaceEntries);
|
|
3789
|
+
}
|
|
3153
3790
|
return uploadToS3_default({
|
|
3154
3791
|
bucket: config2.bucket || void 0,
|
|
3155
3792
|
inputStream: await zip_default({
|
|
@@ -3158,15 +3795,15 @@ async function uploadApplicationSource({
|
|
|
3158
3795
|
onError: (e) => {
|
|
3159
3796
|
throw e;
|
|
3160
3797
|
},
|
|
3161
|
-
onProgress({ fs:
|
|
3162
|
-
totalBytes =
|
|
3798
|
+
onProgress({ fs: fs7 }) {
|
|
3799
|
+
totalBytes = fs7.totalBytes;
|
|
3163
3800
|
},
|
|
3164
|
-
appPkgJson
|
|
3801
|
+
appPkgJson: effectiveAppPkgJson
|
|
3165
3802
|
}),
|
|
3166
3803
|
key: generateS3Key_default({
|
|
3167
3804
|
appId,
|
|
3168
3805
|
buildId,
|
|
3169
|
-
filenameSuffix: `${(
|
|
3806
|
+
filenameSuffix: `${(_a2 = effectiveAppPkgJson.name) == null ? void 0 : _a2.replaceAll("/", "")}.zip`
|
|
3170
3807
|
}),
|
|
3171
3808
|
onProgress({ loaded, total }) {
|
|
3172
3809
|
onProgress(loaded / total * 100, loaded);
|
|
@@ -3175,7 +3812,7 @@ async function uploadApplicationSource({
|
|
|
3175
3812
|
}
|
|
3176
3813
|
async function exists(filePath) {
|
|
3177
3814
|
try {
|
|
3178
|
-
await
|
|
3815
|
+
await fs6.promises.access(filePath);
|
|
3179
3816
|
return true;
|
|
3180
3817
|
} catch (e) {
|
|
3181
3818
|
return false;
|
|
@@ -3188,9 +3825,9 @@ async function runBuild({
|
|
|
3188
3825
|
updateState,
|
|
3189
3826
|
flags
|
|
3190
3827
|
}) {
|
|
3191
|
-
var
|
|
3828
|
+
var _a2, _b, _c, _d;
|
|
3192
3829
|
logForCI_default("Getting application information...");
|
|
3193
|
-
const primaryUserId = (
|
|
3830
|
+
const primaryUserId = (_a2 = currentUser()) == null ? void 0 : _a2.uid;
|
|
3194
3831
|
const { config: config2, unprocessedConfig } = getProjectConfig(configPath, {
|
|
3195
3832
|
build: flags
|
|
3196
3833
|
});
|
|
@@ -3285,9 +3922,9 @@ async function runBuild({
|
|
|
3285
3922
|
}
|
|
3286
3923
|
}
|
|
3287
3924
|
function addErrorMessage(e, message2) {
|
|
3288
|
-
var
|
|
3925
|
+
var _a2, _b;
|
|
3289
3926
|
let originalMessage = "";
|
|
3290
|
-
if (import_axios2.default.isAxiosError(e) && ((_b = (
|
|
3927
|
+
if (import_axios2.default.isAxiosError(e) && ((_b = (_a2 = e.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.message)) {
|
|
3291
3928
|
originalMessage = e.response.data.message;
|
|
3292
3929
|
} else if (e instanceof Error) {
|
|
3293
3930
|
originalMessage = e.message;
|
|
@@ -3310,7 +3947,7 @@ function Build({
|
|
|
3310
3947
|
configPath,
|
|
3311
3948
|
flags
|
|
3312
3949
|
}) {
|
|
3313
|
-
var
|
|
3950
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3314
3951
|
const exit = useExit_default();
|
|
3315
3952
|
const [state, setState] = (0, import_react6.useState)({ state: "initializing" });
|
|
3316
3953
|
(0, import_react6.useEffect)(() => {
|
|
@@ -3320,8 +3957,8 @@ function Build({
|
|
|
3320
3957
|
updateState({ state: "error", error });
|
|
3321
3958
|
});
|
|
3322
3959
|
return () => {
|
|
3323
|
-
var
|
|
3324
|
-
return (
|
|
3960
|
+
var _a3;
|
|
3961
|
+
return (_a3 = state.onUnmount) == null ? void 0 : _a3.call(state);
|
|
3325
3962
|
};
|
|
3326
3963
|
}, []);
|
|
3327
3964
|
function updateState(changes) {
|
|
@@ -3344,7 +3981,7 @@ function Build({
|
|
|
3344
3981
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3345
3982
|
MainLayout_default,
|
|
3346
3983
|
{
|
|
3347
|
-
appName: state.build.appName || ((
|
|
3984
|
+
appName: state.build.appName || ((_a2 = state.appPkg) == null ? void 0 : _a2.name) || "",
|
|
3348
3985
|
appVersion: state.build.appVersion || ((_b = state.appPkg) == null ? void 0 : _b.version) || "",
|
|
3349
3986
|
build: state.build,
|
|
3350
3987
|
commandUsed,
|
|
@@ -3424,8 +4061,7 @@ var loginFields = [
|
|
|
3424
4061
|
placeholder: "name@email.com",
|
|
3425
4062
|
Input: TextInput_default,
|
|
3426
4063
|
validate: (value) => {
|
|
3427
|
-
if (!value)
|
|
3428
|
-
return "Required";
|
|
4064
|
+
if (!value) return "Required";
|
|
3429
4065
|
}
|
|
3430
4066
|
},
|
|
3431
4067
|
{
|
|
@@ -3434,8 +4070,7 @@ var loginFields = [
|
|
|
3434
4070
|
placeholder: "********",
|
|
3435
4071
|
Input: TextInput_default,
|
|
3436
4072
|
validate: (value) => {
|
|
3437
|
-
if (!value)
|
|
3438
|
-
return "Required";
|
|
4073
|
+
if (!value) return "Required";
|
|
3439
4074
|
},
|
|
3440
4075
|
mask: "*"
|
|
3441
4076
|
}
|
|
@@ -3451,7 +4086,7 @@ var Login = ({ setIsLoggedIn }) => {
|
|
|
3451
4086
|
setActiveField(0);
|
|
3452
4087
|
};
|
|
3453
4088
|
const onSubmitLogin = async ({ email, accessToken }) => {
|
|
3454
|
-
var
|
|
4089
|
+
var _a2, _b;
|
|
3455
4090
|
setFailureMessage(null);
|
|
3456
4091
|
setIsSubmittingForm(true);
|
|
3457
4092
|
try {
|
|
@@ -3471,13 +4106,12 @@ var Login = ({ setIsLoggedIn }) => {
|
|
|
3471
4106
|
setError(err);
|
|
3472
4107
|
} else {
|
|
3473
4108
|
onFailure(
|
|
3474
|
-
`Login unsuccessful: ${((_b = (
|
|
4109
|
+
`Login unsuccessful: ${((_b = (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.message) || err.message}`
|
|
3475
4110
|
);
|
|
3476
4111
|
}
|
|
3477
4112
|
}
|
|
3478
4113
|
};
|
|
3479
|
-
if (error)
|
|
3480
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ErrorDisplay, { error });
|
|
4114
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ErrorDisplay, { error });
|
|
3481
4115
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3482
4116
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ink14.Text, { children: "You are not currently logged in." }),
|
|
3483
4117
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ink14.Text, { children: "Log in below:" }),
|
|
@@ -3563,8 +4197,7 @@ var LoginHOC = ({ children, isInteractive = true }) => {
|
|
|
3563
4197
|
);
|
|
3564
4198
|
if (newJwtToken) {
|
|
3565
4199
|
userCreds = await signInWithCustomToken(newJwtToken);
|
|
3566
|
-
if (userCreds.user)
|
|
3567
|
-
setIsLoggedIn(true);
|
|
4200
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
3568
4201
|
}
|
|
3569
4202
|
} else if (!isRawModeSupported || import_is_ci4.default) {
|
|
3570
4203
|
setError(
|
|
@@ -3582,8 +4215,7 @@ var LoginHOC = ({ children, isInteractive = true }) => {
|
|
|
3582
4215
|
try {
|
|
3583
4216
|
if (!userCreds && jwtToken) {
|
|
3584
4217
|
userCreds = await signInWithCustomToken(jwtToken);
|
|
3585
|
-
if (userCreds.user)
|
|
3586
|
-
setIsLoggedIn(true);
|
|
4218
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
3587
4219
|
}
|
|
3588
4220
|
} catch (err) {
|
|
3589
4221
|
}
|
|
@@ -3596,8 +4228,7 @@ var LoginHOC = ({ children, isInteractive = true }) => {
|
|
|
3596
4228
|
if (newJwtToken) {
|
|
3597
4229
|
userCreds = await signInWithCustomToken(newJwtToken);
|
|
3598
4230
|
setAuthConfig(email, accessToken, newJwtToken);
|
|
3599
|
-
if (userCreds.user)
|
|
3600
|
-
setIsLoggedIn(true);
|
|
4231
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
3601
4232
|
}
|
|
3602
4233
|
}
|
|
3603
4234
|
} catch (err) {
|
|
@@ -3714,7 +4345,7 @@ async function subscribeToFirebaseDoc(key, receiver) {
|
|
|
3714
4345
|
(snapshot) => {
|
|
3715
4346
|
receiver({
|
|
3716
4347
|
snapshot,
|
|
3717
|
-
data:
|
|
4348
|
+
data: readDocumentSnapshot(snapshot)
|
|
3718
4349
|
});
|
|
3719
4350
|
resolve5(unsubscribe);
|
|
3720
4351
|
},
|
|
@@ -3744,15 +4375,21 @@ var subscribeToBuild_default = async ({ appId, buildId, onDataReceived, userId }
|
|
|
3744
4375
|
var import_firestore12 = require("firebase/firestore");
|
|
3745
4376
|
var getCollection = async (collectionRef) => {
|
|
3746
4377
|
const resp = await (0, import_firestore12.getDocs)(collectionRef);
|
|
3747
|
-
|
|
3748
|
-
resp.forEach((doc9) => result.push(doc9.data()));
|
|
3749
|
-
return result;
|
|
4378
|
+
return readQuerySnapshot(resp);
|
|
3750
4379
|
};
|
|
3751
4380
|
var acceptedUsersCollection = (id) => (0, import_firestore12.collection)(firestore_default, `users/${id}/acceptedUsers`);
|
|
3752
4381
|
var findAppUserId = async (appId) => {
|
|
3753
|
-
const
|
|
3754
|
-
|
|
3755
|
-
|
|
4382
|
+
const authUser = currentUser();
|
|
4383
|
+
if (!(authUser == null ? void 0 : authUser.uid)) {
|
|
4384
|
+
throw new Error("A signed-in Firebase user is required");
|
|
4385
|
+
}
|
|
4386
|
+
const acceptedUsers = await getCollection(
|
|
4387
|
+
acceptedUsersCollection(authUser.uid)
|
|
4388
|
+
);
|
|
4389
|
+
const primaryUser = {
|
|
4390
|
+
id: authUser.uid,
|
|
4391
|
+
label: authUser.email ?? authUser.uid
|
|
4392
|
+
};
|
|
3756
4393
|
const users = [
|
|
3757
4394
|
primaryUser,
|
|
3758
4395
|
...acceptedUsers.map((user) => ({ id: user.id, label: user.email }))
|
|
@@ -3761,8 +4398,7 @@ var findAppUserId = async (appId) => {
|
|
|
3761
4398
|
try {
|
|
3762
4399
|
const docRef = (0, import_firestore12.doc)(firestore_default, `users/${user.id}/applications/${appId}`);
|
|
3763
4400
|
const docSnap = await (0, import_firestore12.getDoc)(docRef);
|
|
3764
|
-
if (docSnap.exists())
|
|
3765
|
-
return user;
|
|
4401
|
+
if (docSnap.exists()) return user;
|
|
3766
4402
|
} catch (err) {
|
|
3767
4403
|
console.error(err);
|
|
3768
4404
|
}
|
|
@@ -3958,7 +4594,7 @@ var OngoingBuildGuard = ({
|
|
|
3958
4594
|
try {
|
|
3959
4595
|
const applicationId = getProjectConfig(configPath).config.id;
|
|
3960
4596
|
const { id } = await findAppUserId_default(applicationId);
|
|
3961
|
-
const now = new Date();
|
|
4597
|
+
const now = /* @__PURE__ */ new Date();
|
|
3962
4598
|
const twentyFourHoursAgo = new Date(
|
|
3963
4599
|
now.getTime() - 24 * 60 * 60 * 1e3
|
|
3964
4600
|
);
|
|
@@ -3978,13 +4614,13 @@ var OngoingBuildGuard = ({
|
|
|
3978
4614
|
builds: []
|
|
3979
4615
|
};
|
|
3980
4616
|
if (!buildsResult.empty) {
|
|
3981
|
-
const latestBuild = buildsResult.docs[0]
|
|
4617
|
+
const latestBuild = readQueryDocument(buildsResult.docs[0]);
|
|
3982
4618
|
const isRunning = isBuildRunning(latestBuild) && latestBuild.status !== "preparation";
|
|
3983
4619
|
logger_default.debug(
|
|
3984
4620
|
{ isRunning },
|
|
3985
4621
|
"OngoingBuildGuard component: got latest build"
|
|
3986
4622
|
);
|
|
3987
|
-
stateUpdates.builds = buildsResult.docs.map((doc9) => doc9
|
|
4623
|
+
stateUpdates.builds = buildsResult.docs.map((doc9) => readQueryDocument(doc9)).filter((build) => {
|
|
3988
4624
|
if (isBuildRunning(build) && build.status !== "preparation") {
|
|
3989
4625
|
return true;
|
|
3990
4626
|
}
|
|
@@ -4372,12 +5008,12 @@ async function getBuilds({
|
|
|
4372
5008
|
if (buildsResult.empty) {
|
|
4373
5009
|
return [];
|
|
4374
5010
|
}
|
|
4375
|
-
return buildsResult
|
|
5011
|
+
return readQuerySnapshot(buildsResult);
|
|
4376
5012
|
}
|
|
4377
5013
|
|
|
4378
5014
|
// src/utilities/getRelativeDateFromDateString.ts
|
|
4379
5015
|
var dateFns = __toESM(require("date-fns"));
|
|
4380
|
-
var getRelativeDateFromDateString_default = (input) => dateFns.formatDistance(new Date(input), new Date()) + " ago";
|
|
5016
|
+
var getRelativeDateFromDateString_default = (input) => dateFns.formatDistance(new Date(input), /* @__PURE__ */ new Date()) + " ago";
|
|
4381
5017
|
|
|
4382
5018
|
// src/components/SyntaxHighlight.tsx
|
|
4383
5019
|
var import_chalk2 = __toESM(require("chalk"));
|
|
@@ -4759,7 +5395,7 @@ async function getBuildById({
|
|
|
4759
5395
|
if (!snapshot.exists()) {
|
|
4760
5396
|
return null;
|
|
4761
5397
|
}
|
|
4762
|
-
return snapshot
|
|
5398
|
+
return readDocumentSnapshot(snapshot) ?? null;
|
|
4763
5399
|
}
|
|
4764
5400
|
|
|
4765
5401
|
// src/utilities/getLatestReleasedBuild.ts
|
|
@@ -4767,14 +5403,14 @@ async function getLatestReleasedBuild({
|
|
|
4767
5403
|
appId,
|
|
4768
5404
|
userId
|
|
4769
5405
|
}) {
|
|
4770
|
-
var
|
|
5406
|
+
var _a2, _b;
|
|
4771
5407
|
const appRef = (0, import_firestore21.doc)(firestore_default, `users/${userId}/applications/${appId}`);
|
|
4772
5408
|
const appSnapshot = await (0, import_firestore21.getDoc)(appRef);
|
|
4773
|
-
const app2 =
|
|
5409
|
+
const app2 = readDocumentSnapshot(appSnapshot);
|
|
4774
5410
|
if (!app2) {
|
|
4775
5411
|
throw new Error(`Application with ID of ${appId} doesn't exist.`);
|
|
4776
5412
|
}
|
|
4777
|
-
if ((
|
|
5413
|
+
if ((_a2 = app2.meta) == null ? void 0 : _a2.latestReleaseBuildId) {
|
|
4778
5414
|
return await getBuildById({
|
|
4779
5415
|
buildId: (_b = app2.meta) == null ? void 0 : _b.latestReleaseBuildId,
|
|
4780
5416
|
appId,
|
|
@@ -4787,7 +5423,7 @@ async function getLatestReleasedBuild({
|
|
|
4787
5423
|
(0, import_firestore21.limit)(1)
|
|
4788
5424
|
);
|
|
4789
5425
|
const buildsResult = await (0, import_firestore21.getDocs)(buildsQuery);
|
|
4790
|
-
return buildsResult.empty ? void 0 : buildsResult.docs[0]
|
|
5426
|
+
return buildsResult.empty ? void 0 : readQueryDocument(buildsResult.docs[0]);
|
|
4791
5427
|
}
|
|
4792
5428
|
|
|
4793
5429
|
// src/components/BuildPicker.tsx
|
|
@@ -4931,6 +5567,7 @@ async function getBuildAttributes({
|
|
|
4931
5567
|
buildId,
|
|
4932
5568
|
configPath
|
|
4933
5569
|
}) {
|
|
5570
|
+
var _a2;
|
|
4934
5571
|
const {
|
|
4935
5572
|
id: appId,
|
|
4936
5573
|
nodeVersion,
|
|
@@ -4938,7 +5575,7 @@ async function getBuildAttributes({
|
|
|
4938
5575
|
pnpmVersion
|
|
4939
5576
|
} = getProjectConfig(configPath).config;
|
|
4940
5577
|
const { id: userId } = await findAppUserId_default(appId);
|
|
4941
|
-
const
|
|
5578
|
+
const contextUserId = (_a2 = currentUser()) == null ? void 0 : _a2.uid;
|
|
4942
5579
|
const build = await fetchBuild({ appId, buildId, userId });
|
|
4943
5580
|
return {
|
|
4944
5581
|
appId,
|
|
@@ -5017,7 +5654,7 @@ function ReleaseBuildView({
|
|
|
5017
5654
|
commandUsed,
|
|
5018
5655
|
state
|
|
5019
5656
|
}) {
|
|
5020
|
-
var
|
|
5657
|
+
var _a2, _b;
|
|
5021
5658
|
switch (state.state) {
|
|
5022
5659
|
case "build-error": {
|
|
5023
5660
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
@@ -5025,7 +5662,7 @@ function ReleaseBuildView({
|
|
|
5025
5662
|
{
|
|
5026
5663
|
build: state.build,
|
|
5027
5664
|
description: "Can't release build",
|
|
5028
|
-
message: ((
|
|
5665
|
+
message: ((_a2 = state.error) == null ? void 0 : _a2.message) || "Internal build error"
|
|
5029
5666
|
}
|
|
5030
5667
|
);
|
|
5031
5668
|
}
|
|
@@ -5128,7 +5765,7 @@ var defaultVM = {
|
|
|
5128
5765
|
imageVersion: ""
|
|
5129
5766
|
};
|
|
5130
5767
|
function makeProgress(build) {
|
|
5131
|
-
var
|
|
5768
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
5132
5769
|
const defaultProgress = {
|
|
5133
5770
|
message: "Starting",
|
|
5134
5771
|
progress: 0,
|
|
@@ -5138,7 +5775,7 @@ function makeProgress(build) {
|
|
|
5138
5775
|
};
|
|
5139
5776
|
const linux = {
|
|
5140
5777
|
...defaultProgress,
|
|
5141
|
-
...(
|
|
5778
|
+
...(_a2 = build.smokeTest) == null ? void 0 : _a2.linux,
|
|
5142
5779
|
shouldSkip: ((_b = build.linux) == null ? void 0 : _b.shouldSkip) || false
|
|
5143
5780
|
};
|
|
5144
5781
|
const mac = {
|
|
@@ -5352,7 +5989,7 @@ function ReleaseConfirmation({
|
|
|
5352
5989
|
disabled = false,
|
|
5353
5990
|
loadData = loadBuildsData
|
|
5354
5991
|
}) {
|
|
5355
|
-
var
|
|
5992
|
+
var _a2;
|
|
5356
5993
|
const [state, setState] = (0, import_react20.useState)({
|
|
5357
5994
|
state: disabled ? "bypass" : "loading"
|
|
5358
5995
|
});
|
|
@@ -5377,7 +6014,7 @@ function ReleaseConfirmation({
|
|
|
5377
6014
|
{
|
|
5378
6015
|
build: state.build,
|
|
5379
6016
|
description: "Can't release build",
|
|
5380
|
-
message: ((
|
|
6017
|
+
message: ((_a2 = state.error) == null ? void 0 : _a2.message) || "Internal build error"
|
|
5381
6018
|
}
|
|
5382
6019
|
);
|
|
5383
6020
|
}
|
|
@@ -5714,7 +6351,7 @@ function SmokeTestView({
|
|
|
5714
6351
|
commandUsed = "",
|
|
5715
6352
|
state
|
|
5716
6353
|
}) {
|
|
5717
|
-
var
|
|
6354
|
+
var _a2, _b, _c, _d;
|
|
5718
6355
|
switch (state.state) {
|
|
5719
6356
|
case "build-error": {
|
|
5720
6357
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
@@ -5722,7 +6359,7 @@ function SmokeTestView({
|
|
|
5722
6359
|
{
|
|
5723
6360
|
build: state.build,
|
|
5724
6361
|
description: "Can't finish smoke test",
|
|
5725
|
-
message: (
|
|
6362
|
+
message: (_a2 = state.error) == null ? void 0 : _a2.message
|
|
5726
6363
|
}
|
|
5727
6364
|
);
|
|
5728
6365
|
}
|
|
@@ -5771,12 +6408,12 @@ async function cancelSmokeTest({
|
|
|
5771
6408
|
buildId,
|
|
5772
6409
|
userId
|
|
5773
6410
|
}) {
|
|
5774
|
-
var
|
|
6411
|
+
var _a2;
|
|
5775
6412
|
await postToFirebaseFunction_default("cancelSmokeTest_HTTP", {
|
|
5776
6413
|
appId,
|
|
5777
6414
|
buildId,
|
|
5778
6415
|
userId,
|
|
5779
|
-
idToken: await ((
|
|
6416
|
+
idToken: await ((_a2 = currentUser()) == null ? void 0 : _a2.getIdToken())
|
|
5780
6417
|
});
|
|
5781
6418
|
}
|
|
5782
6419
|
|
|
@@ -5790,7 +6427,7 @@ async function queueSmokeTest({
|
|
|
5790
6427
|
pnpmVersion,
|
|
5791
6428
|
userId
|
|
5792
6429
|
}) {
|
|
5793
|
-
var
|
|
6430
|
+
var _a2;
|
|
5794
6431
|
try {
|
|
5795
6432
|
await postToFirebaseFunction_default("queueSmokeTest_HTTP", {
|
|
5796
6433
|
appId,
|
|
@@ -5800,7 +6437,7 @@ async function queueSmokeTest({
|
|
|
5800
6437
|
pnpmVersion,
|
|
5801
6438
|
userId,
|
|
5802
6439
|
contextUserId,
|
|
5803
|
-
idToken: await ((
|
|
6440
|
+
idToken: await ((_a2 = currentUser()) == null ? void 0 : _a2.getIdToken())
|
|
5804
6441
|
});
|
|
5805
6442
|
} catch (e) {
|
|
5806
6443
|
logger_default.error({ error: e });
|
|
@@ -5821,7 +6458,10 @@ async function waitUntilFinished({
|
|
|
5821
6458
|
const unsubscribe = (0, import_firestore27.onSnapshot)(
|
|
5822
6459
|
(0, import_firestore27.doc)(firestore_default, docPath),
|
|
5823
6460
|
(snapshot) => {
|
|
5824
|
-
const data =
|
|
6461
|
+
const data = readDocumentSnapshot(snapshot);
|
|
6462
|
+
if (!data) {
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
5825
6465
|
const progress = makeProgress(data);
|
|
5826
6466
|
onProgress(progress);
|
|
5827
6467
|
if (progress.isFinished) {
|
|
@@ -5956,8 +6596,8 @@ async function smokeTestWorkflow({
|
|
|
5956
6596
|
}
|
|
5957
6597
|
}
|
|
5958
6598
|
function buildCanBeCanceled(build) {
|
|
5959
|
-
var
|
|
5960
|
-
if ((
|
|
6599
|
+
var _a2, _b;
|
|
6600
|
+
if ((_a2 = build == null ? void 0 : build.smokeTest) == null ? void 0 : _a2.isCanceled) {
|
|
5961
6601
|
return false;
|
|
5962
6602
|
}
|
|
5963
6603
|
return Boolean((_b = build == null ? void 0 : build.smokeTest) == null ? void 0 : _b.buildServerExecutionId);
|
|
@@ -6001,7 +6641,7 @@ var exitIfCLIOutOfDate_default = () => {
|
|
|
6001
6641
|
(0, import_latest_version.default)(pkg.name).then((latest) => {
|
|
6002
6642
|
if (import_semver3.default.gt(latest, pkg.version)) {
|
|
6003
6643
|
const commandToUpdate = import_chalk3.default.greenBright(
|
|
6004
|
-
`npm install ${import_is_installed_globally.default ? "
|
|
6644
|
+
`npm install ${import_is_installed_globally.default ? "-g" : "--save-dev"} @todesktop/cli`
|
|
6005
6645
|
);
|
|
6006
6646
|
console.log(
|
|
6007
6647
|
`Your version of @todesktop/cli is out of date.
|
|
@@ -6026,7 +6666,7 @@ var package_default = {
|
|
|
6026
6666
|
access: "public"
|
|
6027
6667
|
},
|
|
6028
6668
|
name: "@todesktop/cli",
|
|
6029
|
-
version: "1.
|
|
6669
|
+
version: "1.18.0",
|
|
6030
6670
|
license: "MIT",
|
|
6031
6671
|
author: "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
|
|
6032
6672
|
homepage: "https://todesktop.com/cli",
|
|
@@ -6041,23 +6681,23 @@ var package_default = {
|
|
|
6041
6681
|
node: ">=16"
|
|
6042
6682
|
},
|
|
6043
6683
|
scripts: {
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
"dev:local:prod": "
|
|
6047
|
-
|
|
6048
|
-
"
|
|
6684
|
+
build: "scripts/esbuild.js",
|
|
6685
|
+
dev: "scripts/esbuild.js --link --watch --stage dev",
|
|
6686
|
+
"dev:local:prod": "scripts/esbuild.js --link --watch --stage prod-local",
|
|
6687
|
+
"dev:prod": "scripts/esbuild.js --link --watch",
|
|
6688
|
+
"docs:generate": "node scripts/generate-readme.js",
|
|
6689
|
+
format: "prettier --write .",
|
|
6049
6690
|
lint: "npm run lint:types && npm run lint:styles",
|
|
6691
|
+
"lint--fix": "eslint src test --fix",
|
|
6050
6692
|
"lint:styles": "eslint src test .eslintrc.js && prettier --check .",
|
|
6051
|
-
format: "prettier --write .",
|
|
6052
6693
|
"lint:types": "tsc && tsc-strict",
|
|
6053
|
-
"lint--fix": "eslint src test --fix",
|
|
6054
|
-
"docs:generate": "node scripts/generate-readme.js",
|
|
6055
6694
|
"types:generate": "node scripts/generate-types.js",
|
|
6056
|
-
release: "npm run docs:generate && npm run build &&
|
|
6695
|
+
release: "npm run docs:generate && npm run build && pnpx np --tag=latest",
|
|
6057
6696
|
"release-beta": "npm run docs:generate && npm run build && npx np --any-branch --no-tests --tag=beta",
|
|
6058
6697
|
test: "ava",
|
|
6698
|
+
"test:e2e": "node test/output-snapshots/output.test.js",
|
|
6059
6699
|
"test--watch": "npm test -- --watch",
|
|
6060
|
-
|
|
6700
|
+
typecheck: "tsc --noEmit"
|
|
6061
6701
|
},
|
|
6062
6702
|
files: [
|
|
6063
6703
|
"scripts/postinstall.js",
|
|
@@ -6094,6 +6734,7 @@ var package_default = {
|
|
|
6094
6734
|
"ink-text-input": "^4.0.1",
|
|
6095
6735
|
"is-ci": "^3.0.1",
|
|
6096
6736
|
"is-installed-globally": "^0.3.2",
|
|
6737
|
+
"js-yaml": "^4.1.0",
|
|
6097
6738
|
"latest-version": "^5.1.0",
|
|
6098
6739
|
"lodash.merge": "^4.6.2",
|
|
6099
6740
|
"lodash.throttle": "^4.1.1",
|
|
@@ -6111,6 +6752,7 @@ var package_default = {
|
|
|
6111
6752
|
"xdg-basedir": "^4.0.0"
|
|
6112
6753
|
},
|
|
6113
6754
|
devDependencies: {
|
|
6755
|
+
"@todesktop/dev-config": "workspace:*",
|
|
6114
6756
|
"@todesktop/shared": "^7.189.6",
|
|
6115
6757
|
"@types/bunyan": "^1.8.6",
|
|
6116
6758
|
"@types/is-ci": "^3.0.4",
|
|
@@ -6120,7 +6762,7 @@ var package_default = {
|
|
|
6120
6762
|
"@typescript-eslint/parser": "^5.46.1",
|
|
6121
6763
|
ava: "^4.3.1",
|
|
6122
6764
|
"cp-cli": "^2.0.0",
|
|
6123
|
-
esbuild: "^0.
|
|
6765
|
+
esbuild: "^0.25.10",
|
|
6124
6766
|
"esbuild-register": "^3.4.1",
|
|
6125
6767
|
eslint: "^8.29.0",
|
|
6126
6768
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -6142,7 +6784,7 @@ var package_default = {
|
|
|
6142
6784
|
prettier: "^2.8.1",
|
|
6143
6785
|
proxyquire: "^2.1.3",
|
|
6144
6786
|
sinon: "^9.0.3",
|
|
6145
|
-
typescript: "
|
|
6787
|
+
typescript: "catalog:",
|
|
6146
6788
|
"typescript-strict-plugin": "^2.2.1"
|
|
6147
6789
|
},
|
|
6148
6790
|
ava: {
|
|
@@ -6176,18 +6818,6 @@ var package_default = {
|
|
|
6176
6818
|
"pre-commit": "lint-staged"
|
|
6177
6819
|
}
|
|
6178
6820
|
},
|
|
6179
|
-
overrides: {
|
|
6180
|
-
pastel: {
|
|
6181
|
-
"parcel-bundler": {
|
|
6182
|
-
deasync: "0.1.27"
|
|
6183
|
-
}
|
|
6184
|
-
}
|
|
6185
|
-
},
|
|
6186
|
-
resolutions: {
|
|
6187
|
-
"pastel/parcel-bundler/deasync": "0.1.24",
|
|
6188
|
-
ink: "3.2.0",
|
|
6189
|
-
react: "17.0.2"
|
|
6190
|
-
},
|
|
6191
6821
|
packageExtensions: {
|
|
6192
6822
|
"ink-progress-bar@*": {
|
|
6193
6823
|
dependencies: {
|