@todesktop/cli 1.13.0 → 1.15.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 +86 -26
- package/dist/cli.js +244 -92
- package/dist/cli.js.map +4 -4
- package/dist/types.d.ts +503 -0
- package/package.json +8 -5
- package/schemas/schema.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -158,8 +158,9 @@ var init = () => {
|
|
|
158
158
|
if (hasInitialized) {
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
+
const envFile = process.env.NODE_ENV === "test" ? "../.env.test" : "../.env";
|
|
161
162
|
import_dotenv.default.config({
|
|
162
|
-
path: import_path.default.resolve(__dirname,
|
|
163
|
+
path: import_path.default.resolve(__dirname, envFile)
|
|
163
164
|
});
|
|
164
165
|
hasInitialized = true;
|
|
165
166
|
};
|
|
@@ -169,11 +170,11 @@ var getEnvironmentVariables_default = () => {
|
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
// src/utilities/firestore.ts
|
|
172
|
-
var import_app =
|
|
173
|
+
var import_app = require("firebase/app");
|
|
173
174
|
var import_firestore = require("firebase/firestore");
|
|
174
175
|
var import_auth = require("firebase/auth");
|
|
175
176
|
var environmentVariables = getEnvironmentVariables_default();
|
|
176
|
-
var
|
|
177
|
+
var firebaseApp = (0, import_app.initializeApp)({
|
|
177
178
|
apiKey: environmentVariables.TODESKTOP_CLI_FIREBASE_API_KEY,
|
|
178
179
|
authDomain: environmentVariables.TODESKTOP_CLI_FIREBASE_AUTH_DOMAIN,
|
|
179
180
|
databaseURL: environmentVariables.TODESKTOP_CLI_FIREBASE_DATABASE_URL,
|
|
@@ -182,14 +183,16 @@ var firebaseDB = import_app.default.initializeApp({
|
|
|
182
183
|
messagingSenderId: environmentVariables.TODESKTOP_CLI_FIREBASE_MESSAGING_SENDER_ID,
|
|
183
184
|
appId: environmentVariables.TODESKTOP_CLI_FIREBASE_ID
|
|
184
185
|
});
|
|
185
|
-
var
|
|
186
|
+
var auth = (0, import_auth.getAuth)(firebaseApp);
|
|
187
|
+
var db = (0, import_firestore.getFirestore)(firebaseApp);
|
|
188
|
+
var currentUser = () => auth.currentUser;
|
|
186
189
|
var signInWithCustomToken = async (token) => {
|
|
187
|
-
return
|
|
190
|
+
return (0, import_auth.signInWithCustomToken)(auth, token);
|
|
188
191
|
};
|
|
189
|
-
var onUserAuth = (handler) =>
|
|
192
|
+
var onUserAuth = (handler) => (0, import_auth.onAuthStateChanged)(auth, (user) => {
|
|
190
193
|
handler(user || {});
|
|
191
194
|
});
|
|
192
|
-
var firestore_default =
|
|
195
|
+
var firestore_default = db;
|
|
193
196
|
|
|
194
197
|
// src/utilities/configStore.ts
|
|
195
198
|
var fs2 = __toESM(require("fs"));
|
|
@@ -339,14 +342,11 @@ var useExit_default = () => {
|
|
|
339
342
|
const { exit } = (0, import_ink.useApp)();
|
|
340
343
|
return (error) => {
|
|
341
344
|
logger_default.debug({ error }, "Exit called");
|
|
342
|
-
firestore_default.terminate().catch(
|
|
343
|
-
(e) => logger_default.error(e)
|
|
344
|
-
);
|
|
345
345
|
let timeoutId;
|
|
346
346
|
Promise.race([
|
|
347
|
-
new Promise((
|
|
347
|
+
new Promise((resolve5) => flush(() => resolve5())),
|
|
348
348
|
new Promise(
|
|
349
|
-
(
|
|
349
|
+
(resolve5) => timeoutId = setTimeout(() => resolve5(), 1e3)
|
|
350
350
|
)
|
|
351
351
|
]).catch(() => {
|
|
352
352
|
}).finally(() => {
|
|
@@ -624,14 +624,28 @@ var import_ink6 = require("ink");
|
|
|
624
624
|
var import_react4 = require("react");
|
|
625
625
|
|
|
626
626
|
// src/utilities/getCallableFirebaseFunction.ts
|
|
627
|
-
var import_firebase = __toESM(require("firebase"));
|
|
628
627
|
var import_functions = require("firebase/functions");
|
|
628
|
+
var import_app2 = require("firebase/app");
|
|
629
629
|
var env = getEnvironmentVariables_default();
|
|
630
|
+
var app = (0, import_app2.initializeApp)({
|
|
631
|
+
apiKey: env.TODESKTOP_CLI_FIREBASE_API_KEY,
|
|
632
|
+
authDomain: env.TODESKTOP_CLI_FIREBASE_AUTH_DOMAIN,
|
|
633
|
+
databaseURL: env.TODESKTOP_CLI_FIREBASE_DATABASE_URL,
|
|
634
|
+
projectId: env.TODESKTOP_CLI_FIREBASE_PROJECT_ID,
|
|
635
|
+
storageBucket: env.TODESKTOP_CLI_FIREBASE_STORAGE_BUCKET,
|
|
636
|
+
messagingSenderId: env.TODESKTOP_CLI_FIREBASE_MESSAGING_SENDER_ID,
|
|
637
|
+
appId: env.TODESKTOP_CLI_FIREBASE_ID
|
|
638
|
+
});
|
|
639
|
+
var functions = (0, import_functions.getFunctions)(app);
|
|
630
640
|
if (env.TODESKTOP_CLI_ENV === "development") {
|
|
631
641
|
const firebaseUrl = new URL(env.TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE);
|
|
632
|
-
|
|
642
|
+
(0, import_functions.connectFunctionsEmulator)(
|
|
643
|
+
functions,
|
|
644
|
+
firebaseUrl.hostname,
|
|
645
|
+
parseInt(firebaseUrl.port)
|
|
646
|
+
);
|
|
633
647
|
}
|
|
634
|
-
var getCallableFirebaseFunction_default = (functionName) =>
|
|
648
|
+
var getCallableFirebaseFunction_default = (functionName) => (0, import_functions.httpsCallable)(functions, functionName);
|
|
635
649
|
|
|
636
650
|
// src/components/CancelBuild.tsx
|
|
637
651
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1011,10 +1025,101 @@ async function postToFirebaseFunction_default(functionName, body = {}, config2 =
|
|
|
1011
1025
|
// src/utilities/projectConfig/getProjectConfig.ts
|
|
1012
1026
|
var import_find_up = __toESM(require("find-up"));
|
|
1013
1027
|
var import_fs = require("fs");
|
|
1028
|
+
var import_path5 = require("path");
|
|
1029
|
+
|
|
1030
|
+
// src/utilities/projectConfig/loadConfig.ts
|
|
1014
1031
|
var import_path3 = require("path");
|
|
1015
1032
|
|
|
1033
|
+
// src/utilities/projectConfig/loadTypeScriptConfig.ts
|
|
1034
|
+
var import_path2 = require("path");
|
|
1035
|
+
function loadTypeScriptConfig(configPath) {
|
|
1036
|
+
const projectRoot = process.cwd();
|
|
1037
|
+
try {
|
|
1038
|
+
logger_default.debug(`Attempting to load TypeScript config from: ${configPath}`);
|
|
1039
|
+
let typescript;
|
|
1040
|
+
try {
|
|
1041
|
+
const tsPath = (0, import_path2.resolve)(projectRoot, "node_modules", "typescript");
|
|
1042
|
+
typescript = require(tsPath);
|
|
1043
|
+
logger_default.debug(`Found TypeScript in user's project at: ${tsPath}`);
|
|
1044
|
+
} catch (error) {
|
|
1045
|
+
try {
|
|
1046
|
+
typescript = require("typescript");
|
|
1047
|
+
logger_default.debug("Using globally available TypeScript installation");
|
|
1048
|
+
} catch (globalError) {
|
|
1049
|
+
throw new Error(
|
|
1050
|
+
`TypeScript is required to load .ts configuration files but was not found. Please install TypeScript in your project: npm install --save-dev typescript`
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const fs6 = require("fs");
|
|
1055
|
+
const sourceCode = fs6.readFileSync(configPath, "utf8");
|
|
1056
|
+
const result = typescript.transpile(sourceCode, {
|
|
1057
|
+
target: typescript.ScriptTarget.ES2018,
|
|
1058
|
+
module: typescript.ModuleKind.CommonJS,
|
|
1059
|
+
moduleResolution: typescript.ModuleResolutionKind.NodeJs,
|
|
1060
|
+
esModuleInterop: true,
|
|
1061
|
+
allowSyntheticDefaultImports: true,
|
|
1062
|
+
resolveJsonModule: true,
|
|
1063
|
+
declaration: false,
|
|
1064
|
+
sourceMap: false
|
|
1065
|
+
});
|
|
1066
|
+
const module2 = { exports: {} };
|
|
1067
|
+
const moduleWrapper = new Function(
|
|
1068
|
+
"module",
|
|
1069
|
+
"exports",
|
|
1070
|
+
"require",
|
|
1071
|
+
"__filename",
|
|
1072
|
+
"__dirname",
|
|
1073
|
+
result
|
|
1074
|
+
);
|
|
1075
|
+
moduleWrapper(
|
|
1076
|
+
module2,
|
|
1077
|
+
module2.exports,
|
|
1078
|
+
(id) => {
|
|
1079
|
+
if (id.startsWith(".")) {
|
|
1080
|
+
return require((0, import_path2.resolve)(configPath, "..", id));
|
|
1081
|
+
}
|
|
1082
|
+
return require(id);
|
|
1083
|
+
},
|
|
1084
|
+
configPath,
|
|
1085
|
+
(0, import_path2.resolve)(configPath, "..")
|
|
1086
|
+
);
|
|
1087
|
+
const config2 = module2.exports.default || module2.exports;
|
|
1088
|
+
if (!config2 || typeof config2 !== "object") {
|
|
1089
|
+
throw new Error(
|
|
1090
|
+
`TypeScript configuration file must export a configuration object. Received: ${typeof config2}`
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
logger_default.debug("Successfully loaded and compiled TypeScript configuration");
|
|
1094
|
+
return config2;
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
logger_default.error(
|
|
1097
|
+
`Failed to load TypeScript configuration from ${configPath}:`,
|
|
1098
|
+
error
|
|
1099
|
+
);
|
|
1100
|
+
if (error instanceof Error) {
|
|
1101
|
+
if (error.message.includes("Cannot find module")) {
|
|
1102
|
+
throw new Error(
|
|
1103
|
+
`Failed to load TypeScript configuration: ${error.message}. Make sure all imported modules are installed.`
|
|
1104
|
+
);
|
|
1105
|
+
} else if (error.message.includes("TypeScript is required")) {
|
|
1106
|
+
throw error;
|
|
1107
|
+
} else {
|
|
1108
|
+
throw new Error(
|
|
1109
|
+
`Failed to compile TypeScript configuration: ${error.message}. Please check your todesktop.ts file for syntax errors.`
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
throw error;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1016
1117
|
// src/utilities/projectConfig/loadConfig.ts
|
|
1017
1118
|
function loadConfig(configPath) {
|
|
1119
|
+
const extension = (0, import_path3.extname)(configPath);
|
|
1120
|
+
if (extension === ".ts") {
|
|
1121
|
+
return loadTypeScriptConfig(configPath);
|
|
1122
|
+
}
|
|
1018
1123
|
return require(configPath);
|
|
1019
1124
|
}
|
|
1020
1125
|
|
|
@@ -1535,8 +1640,8 @@ var schema_default = {
|
|
|
1535
1640
|
extends: {
|
|
1536
1641
|
type: "string",
|
|
1537
1642
|
minLength: 1,
|
|
1538
|
-
description: "This is the path to a base configuration file. This is especially useful for configuration sharing between staging and production
|
|
1539
|
-
examples: ["./todesktop.
|
|
1643
|
+
description: "This is the path to a base configuration file (`.json` or `.js`). This is especially useful for configuration sharing between different environments (e.g., staging and production). The base configuration file can be a relative path from the project root or an absolute path.",
|
|
1644
|
+
examples: ["./todesktop.base.json", "./todesktop.base.js"],
|
|
1540
1645
|
default: null
|
|
1541
1646
|
},
|
|
1542
1647
|
extraContentFiles: { $ref: "#/definitions/extraContentFilesProperty" },
|
|
@@ -2455,14 +2560,14 @@ ${output}`
|
|
|
2455
2560
|
|
|
2456
2561
|
// src/utilities/projectConfig/computeFullProjectConfig.ts
|
|
2457
2562
|
var import_lodash2 = __toESM(require("lodash.merge"));
|
|
2458
|
-
var
|
|
2563
|
+
var import_path4 = require("path");
|
|
2459
2564
|
function computeFullProjectConfig(partialConfig, projectRoot, flags) {
|
|
2460
2565
|
if (!partialConfig.extends) {
|
|
2461
2566
|
logger_default.debug("No extends field, returning partial config");
|
|
2462
2567
|
return partialConfig;
|
|
2463
2568
|
} else {
|
|
2464
2569
|
logger_default.debug("Extends field found, resolving");
|
|
2465
|
-
const parentConfigPath = (0,
|
|
2570
|
+
const parentConfigPath = (0, import_path4.resolve)(projectRoot, partialConfig.extends);
|
|
2466
2571
|
const parentConfig = loadConfig(parentConfigPath);
|
|
2467
2572
|
parentConfig.appPath = parentConfig.appPath || ".";
|
|
2468
2573
|
const parentFullConfig = computeFullProjectConfig(
|
|
@@ -2496,20 +2601,24 @@ You can disable this error by running todesktop build with the --ignore-extends-
|
|
|
2496
2601
|
function getProjectConfig(configPath, flags) {
|
|
2497
2602
|
if (!configPath) {
|
|
2498
2603
|
logger_default.debug("No config path provided, searching for one");
|
|
2499
|
-
configPath = import_find_up.default.sync(
|
|
2604
|
+
configPath = import_find_up.default.sync([
|
|
2605
|
+
"todesktop.json",
|
|
2606
|
+
"todesktop.js",
|
|
2607
|
+
"todesktop.ts"
|
|
2608
|
+
]);
|
|
2500
2609
|
if (!configPath) {
|
|
2501
2610
|
throw new Error(
|
|
2502
|
-
"Can not find todesktop.json in this folder or any parent folders"
|
|
2611
|
+
"Can not find todesktop.json, todesktop.js, or todesktop.ts in this folder or any parent folders"
|
|
2503
2612
|
);
|
|
2504
2613
|
}
|
|
2505
2614
|
} else {
|
|
2506
|
-
configPath = (0,
|
|
2615
|
+
configPath = (0, import_path5.resolve)(process.cwd(), configPath);
|
|
2507
2616
|
if (!(0, import_fs.existsSync)(configPath)) {
|
|
2508
2617
|
logger_default.error("Provided config path does not exist");
|
|
2509
2618
|
throw new Error(`Config file not found at ${configPath}`);
|
|
2510
2619
|
}
|
|
2511
2620
|
}
|
|
2512
|
-
const projectRoot = (0,
|
|
2621
|
+
const projectRoot = (0, import_path5.dirname)(configPath);
|
|
2513
2622
|
const partialConfig = loadConfig(configPath);
|
|
2514
2623
|
const config2 = computeFullProjectConfig(partialConfig, projectRoot, flags);
|
|
2515
2624
|
validateConfig({ config: config2, projectRoot });
|
|
@@ -2530,7 +2639,7 @@ var shouldExitOnBuildFailure_default = (build) => {
|
|
|
2530
2639
|
|
|
2531
2640
|
// src/commands/build/utilities/getPackageJson.ts
|
|
2532
2641
|
var import_lodash3 = __toESM(require("lodash.merge"));
|
|
2533
|
-
var
|
|
2642
|
+
var import_path6 = __toESM(require("path"));
|
|
2534
2643
|
function deleteNullDeps(dep) {
|
|
2535
2644
|
Object.keys(dep).forEach((key) => {
|
|
2536
2645
|
if (dep[key] === null) {
|
|
@@ -2552,7 +2661,7 @@ function removeNullDependencies(pkgJson) {
|
|
|
2552
2661
|
function getAppPkgJson({ config: config2 }) {
|
|
2553
2662
|
const packageJsonFromConfig = config2.packageJson || {};
|
|
2554
2663
|
const extendsFrom = packageJsonFromConfig.extends || "package.json";
|
|
2555
|
-
const packageJsonFromFile = readJson(
|
|
2664
|
+
const packageJsonFromFile = readJson(import_path6.default.join(config2.appPath, extendsFrom));
|
|
2556
2665
|
return removeNullDependencies(
|
|
2557
2666
|
(0, import_lodash3.default)({}, packageJsonFromFile, packageJsonFromConfig)
|
|
2558
2667
|
);
|
|
@@ -2583,6 +2692,7 @@ var getVersionControlInfo_default = async (directory) => {
|
|
|
2583
2692
|
|
|
2584
2693
|
// src/commands/build/utilities/spyBuild.ts
|
|
2585
2694
|
var import_events = __toESM(require("events"));
|
|
2695
|
+
var import_firestore3 = require("firebase/firestore");
|
|
2586
2696
|
function spyBuild() {
|
|
2587
2697
|
const emitter = new import_events.default();
|
|
2588
2698
|
let unsubscribeSnapshot;
|
|
@@ -2591,10 +2701,10 @@ function spyBuild() {
|
|
|
2591
2701
|
if (latestBuildDoc && predicate(latestBuildDoc)) {
|
|
2592
2702
|
return Promise.resolve(latestBuildDoc);
|
|
2593
2703
|
}
|
|
2594
|
-
return new Promise((
|
|
2704
|
+
return new Promise((resolve5, reject) => {
|
|
2595
2705
|
emitter.on("update", ({ build }) => {
|
|
2596
2706
|
if (predicate(build)) {
|
|
2597
|
-
|
|
2707
|
+
resolve5(build);
|
|
2598
2708
|
}
|
|
2599
2709
|
}).once("error", (e) => reject(e));
|
|
2600
2710
|
});
|
|
@@ -2609,9 +2719,10 @@ function spyBuild() {
|
|
|
2609
2719
|
userId
|
|
2610
2720
|
}) {
|
|
2611
2721
|
const buildPath = `users/${userId}/applications/${appId}/builds/${buildId}`;
|
|
2612
|
-
unsubscribeSnapshot =
|
|
2722
|
+
unsubscribeSnapshot = (0, import_firestore3.onSnapshot)(
|
|
2723
|
+
(0, import_firestore3.doc)(firestore_default, buildPath),
|
|
2613
2724
|
(snapshot) => {
|
|
2614
|
-
latestBuildDoc = snapshot.exists ? snapshot.data() : void 0;
|
|
2725
|
+
latestBuildDoc = snapshot.exists() ? snapshot.data() : void 0;
|
|
2615
2726
|
emitter.emit("update", {
|
|
2616
2727
|
build: latestBuildDoc,
|
|
2617
2728
|
snapshot
|
|
@@ -2629,8 +2740,8 @@ function spyBuild() {
|
|
|
2629
2740
|
if (latestBuildDoc) {
|
|
2630
2741
|
return Promise.resolve(latestBuildDoc);
|
|
2631
2742
|
}
|
|
2632
|
-
return new Promise((
|
|
2633
|
-
emitter.once("update", (data) =>
|
|
2743
|
+
return new Promise((resolve5, reject) => {
|
|
2744
|
+
emitter.once("update", (data) => resolve5(data)).once("error", (e) => reject(e));
|
|
2634
2745
|
});
|
|
2635
2746
|
},
|
|
2636
2747
|
async whenSettled() {
|
|
@@ -2661,7 +2772,7 @@ var import_stream_to_array = __toESM(require("stream-to-array"));
|
|
|
2661
2772
|
var { TODESKTOP_CLI_S3_BUCKET } = getEnvironmentVariables_default();
|
|
2662
2773
|
var MAX_RETRIES = 3;
|
|
2663
2774
|
var RETRY_DELAY = 2e3;
|
|
2664
|
-
var delay = (ms) => new Promise((
|
|
2775
|
+
var delay = (ms) => new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
2665
2776
|
var uploadToS3WithRetry = async (input, retries = MAX_RETRIES) => {
|
|
2666
2777
|
try {
|
|
2667
2778
|
return await uploadToS3(input);
|
|
@@ -2686,22 +2797,23 @@ var uploadToS3 = async ({
|
|
|
2686
2797
|
}
|
|
2687
2798
|
}) => {
|
|
2688
2799
|
const getSignedURL = getCallableFirebaseFunction_default("getSignedURL");
|
|
2689
|
-
const
|
|
2800
|
+
const result = await getSignedURL({
|
|
2690
2801
|
key
|
|
2691
2802
|
});
|
|
2803
|
+
const data = result.data;
|
|
2692
2804
|
const parts = await (0, import_stream_to_array.default)(inputStream);
|
|
2693
2805
|
const buffers = parts.map(
|
|
2694
2806
|
(part) => Buffer.isBuffer(part) ? part : Buffer.from(part)
|
|
2695
2807
|
);
|
|
2696
2808
|
const body = Buffer.concat(buffers);
|
|
2697
|
-
return new Promise((
|
|
2809
|
+
return new Promise((resolve5, reject) => {
|
|
2698
2810
|
import_superagent.default.put(data.signedURL).send(body).set("content-type", "application/zip").on("progress", onProgress).end((err) => {
|
|
2699
2811
|
logger_default.debug({ bucket, key, url: data.uploadURL }, "uploadToS3");
|
|
2700
2812
|
if (err) {
|
|
2701
2813
|
logger_default.error({ err }, "uploadToS3");
|
|
2702
2814
|
return reject(err);
|
|
2703
2815
|
}
|
|
2704
|
-
return
|
|
2816
|
+
return resolve5({ bucket, key, url: data.uploadURL });
|
|
2705
2817
|
});
|
|
2706
2818
|
});
|
|
2707
2819
|
};
|
|
@@ -2712,7 +2824,7 @@ var import_archiver = __toESM(require("archiver"));
|
|
|
2712
2824
|
var import_du = __toESM(require("du"));
|
|
2713
2825
|
var import_fs2 = __toESM(require("fs"));
|
|
2714
2826
|
var import_chalk = __toESM(require("chalk"));
|
|
2715
|
-
var
|
|
2827
|
+
var import_path7 = __toESM(require("path"));
|
|
2716
2828
|
async function zip_default({
|
|
2717
2829
|
files,
|
|
2718
2830
|
fileSizeLimit = 20,
|
|
@@ -2767,7 +2879,7 @@ Your app is larger than ${fileSizeLimit}MB. Your app is ${import_chalk.default.b
|
|
|
2767
2879
|
processedFiles.forEach(({ from, isDirectory, stats, to }) => {
|
|
2768
2880
|
if (isDirectory) {
|
|
2769
2881
|
stream.directory(from, to);
|
|
2770
|
-
} else if (appPkgJson && to ===
|
|
2882
|
+
} else if (appPkgJson && to === import_path7.default.join("app", "package.json")) {
|
|
2771
2883
|
stream.append(JSON.stringify(appPkgJson), {
|
|
2772
2884
|
name: to
|
|
2773
2885
|
});
|
|
@@ -3543,31 +3655,39 @@ var import_prop_types10 = __toESM(require("prop-types"));
|
|
|
3543
3655
|
var import_react11 = require("react");
|
|
3544
3656
|
|
|
3545
3657
|
// src/utilities/getLatestBuildId.ts
|
|
3658
|
+
var import_firestore8 = require("firebase/firestore");
|
|
3546
3659
|
async function getLatestBuildId({
|
|
3547
3660
|
appId,
|
|
3548
3661
|
userId
|
|
3549
3662
|
}) {
|
|
3550
3663
|
logger_default.debug({ appId }, "getLatestBuildId");
|
|
3551
|
-
const appRef =
|
|
3552
|
-
const appSnapshot = await
|
|
3553
|
-
if (!appSnapshot.exists) {
|
|
3664
|
+
const appRef = (0, import_firestore8.doc)(firestore_default, `users/${userId}/applications/${appId}`);
|
|
3665
|
+
const appSnapshot = await (0, import_firestore8.getDoc)(appRef);
|
|
3666
|
+
if (!appSnapshot.exists()) {
|
|
3554
3667
|
throw new Error(`Application with ID of ${appId} doesn't exist.`);
|
|
3555
3668
|
}
|
|
3556
|
-
const
|
|
3669
|
+
const buildsQuery = (0, import_firestore8.query)(
|
|
3670
|
+
(0, import_firestore8.collection)(firestore_default, `users/${userId}/applications/${appId}/builds`),
|
|
3671
|
+
(0, import_firestore8.orderBy)("createdAt", "desc"),
|
|
3672
|
+
(0, import_firestore8.limit)(1)
|
|
3673
|
+
);
|
|
3674
|
+
const buildsResult = await (0, import_firestore8.getDocs)(buildsQuery);
|
|
3557
3675
|
return buildsResult.empty ? void 0 : buildsResult.docs[0].id;
|
|
3558
3676
|
}
|
|
3559
3677
|
|
|
3560
3678
|
// src/utilities/subscribeToFirebaseDoc.ts
|
|
3679
|
+
var import_firestore10 = require("firebase/firestore");
|
|
3561
3680
|
async function subscribeToFirebaseDoc(key, receiver) {
|
|
3562
|
-
return new Promise((
|
|
3681
|
+
return new Promise((resolve5, reject) => {
|
|
3563
3682
|
logger_default.debug({ key }, "subscribeToFirebaseDoc");
|
|
3564
|
-
const unsubscribe =
|
|
3683
|
+
const unsubscribe = (0, import_firestore10.onSnapshot)(
|
|
3684
|
+
(0, import_firestore10.doc)(firestore_default, key),
|
|
3565
3685
|
(snapshot) => {
|
|
3566
3686
|
receiver({
|
|
3567
3687
|
snapshot,
|
|
3568
|
-
data: snapshot.exists ? snapshot.data() : void 0
|
|
3688
|
+
data: snapshot.exists() ? snapshot.data() : void 0
|
|
3569
3689
|
});
|
|
3570
|
-
|
|
3690
|
+
resolve5(unsubscribe);
|
|
3571
3691
|
},
|
|
3572
3692
|
(err) => {
|
|
3573
3693
|
reject(err);
|
|
@@ -3592,14 +3712,14 @@ var subscribeToBuild_default = async ({ appId, buildId, onDataReceived, userId }
|
|
|
3592
3712
|
};
|
|
3593
3713
|
|
|
3594
3714
|
// src/utilities/findAppUserId.ts
|
|
3595
|
-
var
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3715
|
+
var import_firestore12 = require("firebase/firestore");
|
|
3716
|
+
var getCollection = async (collectionRef) => {
|
|
3717
|
+
const resp = await (0, import_firestore12.getDocs)(collectionRef);
|
|
3718
|
+
const result = [];
|
|
3719
|
+
resp.forEach((doc9) => result.push(doc9.data()));
|
|
3720
|
+
return result;
|
|
3601
3721
|
};
|
|
3602
|
-
var acceptedUsersCollection = (id) =>
|
|
3722
|
+
var acceptedUsersCollection = (id) => (0, import_firestore12.collection)(firestore_default, `users/${id}/acceptedUsers`);
|
|
3603
3723
|
var findAppUserId = async (appId) => {
|
|
3604
3724
|
const { uid, email } = currentUser();
|
|
3605
3725
|
const acceptedUsers = await getCollection(acceptedUsersCollection(uid));
|
|
@@ -3610,8 +3730,9 @@ var findAppUserId = async (appId) => {
|
|
|
3610
3730
|
];
|
|
3611
3731
|
for (const user of users) {
|
|
3612
3732
|
try {
|
|
3613
|
-
const
|
|
3614
|
-
|
|
3733
|
+
const docRef = (0, import_firestore12.doc)(firestore_default, `users/${user.id}/applications/${appId}`);
|
|
3734
|
+
const docSnap = await (0, import_firestore12.getDoc)(docRef);
|
|
3735
|
+
if (docSnap.exists())
|
|
3615
3736
|
return user;
|
|
3616
3737
|
} catch (err) {
|
|
3617
3738
|
console.error(err);
|
|
@@ -3782,6 +3903,7 @@ ViewBuild.propTypes = {
|
|
|
3782
3903
|
var ViewBuild_default = ViewBuild;
|
|
3783
3904
|
|
|
3784
3905
|
// src/commands/build/components/OngoingBuildGuard.tsx
|
|
3906
|
+
var import_firestore14 = require("firebase/firestore");
|
|
3785
3907
|
var import_is_ci5 = __toESM(require("is-ci"));
|
|
3786
3908
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3787
3909
|
var OngoingBuildGuard = ({
|
|
@@ -3811,7 +3933,16 @@ var OngoingBuildGuard = ({
|
|
|
3811
3933
|
const twentyFourHoursAgo = new Date(
|
|
3812
3934
|
now.getTime() - 24 * 60 * 60 * 1e3
|
|
3813
3935
|
);
|
|
3814
|
-
const
|
|
3936
|
+
const buildsQuery = (0, import_firestore14.query)(
|
|
3937
|
+
(0, import_firestore14.collection)(
|
|
3938
|
+
firestore_default,
|
|
3939
|
+
`users/${id}/applications/${applicationId}/builds`
|
|
3940
|
+
),
|
|
3941
|
+
(0, import_firestore14.where)("createdAt", ">=", twentyFourHoursAgo),
|
|
3942
|
+
(0, import_firestore14.orderBy)("createdAt", "desc"),
|
|
3943
|
+
(0, import_firestore14.limit)(10)
|
|
3944
|
+
);
|
|
3945
|
+
const buildsResult = await (0, import_firestore14.getDocs)(buildsQuery);
|
|
3815
3946
|
const stateUpdates = {
|
|
3816
3947
|
appId: applicationId,
|
|
3817
3948
|
isLoading: false,
|
|
@@ -3824,7 +3955,7 @@ var OngoingBuildGuard = ({
|
|
|
3824
3955
|
{ isRunning },
|
|
3825
3956
|
"OngoingBuildGuard component: got latest build"
|
|
3826
3957
|
);
|
|
3827
|
-
stateUpdates.builds = buildsResult.docs.map((
|
|
3958
|
+
stateUpdates.builds = buildsResult.docs.map((doc9) => doc9.data()).filter((build) => {
|
|
3828
3959
|
if (isBuildRunning(build) && build.status !== "preparation") {
|
|
3829
3960
|
return true;
|
|
3830
3961
|
}
|
|
@@ -4184,31 +4315,35 @@ var capitalize_default = (input) => {
|
|
|
4184
4315
|
};
|
|
4185
4316
|
|
|
4186
4317
|
// src/utilities/getBuilds.ts
|
|
4318
|
+
var import_firestore17 = require("firebase/firestore");
|
|
4187
4319
|
async function getBuilds({
|
|
4188
|
-
addWhereClauses = (
|
|
4320
|
+
addWhereClauses = () => [],
|
|
4189
4321
|
userId,
|
|
4190
4322
|
appId,
|
|
4191
|
-
limit = 5,
|
|
4323
|
+
limit: limit4 = 5,
|
|
4192
4324
|
startAfter = null
|
|
4193
4325
|
}) {
|
|
4194
|
-
logger_default.debug({ appId, limit, startAfter }, "getBuilds");
|
|
4195
|
-
const appRef =
|
|
4196
|
-
const appSnapshot = await
|
|
4197
|
-
if (!appSnapshot.exists) {
|
|
4326
|
+
logger_default.debug({ appId, limit: limit4, startAfter }, "getBuilds");
|
|
4327
|
+
const appRef = (0, import_firestore17.doc)(firestore_default, `users/${userId}/applications/${appId}`);
|
|
4328
|
+
const appSnapshot = await (0, import_firestore17.getDoc)(appRef);
|
|
4329
|
+
if (!appSnapshot.exists()) {
|
|
4198
4330
|
throw new Error(`Application with ID of ${appId} doesn't exist.`);
|
|
4199
4331
|
}
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4332
|
+
const buildsCollection = (0, import_firestore17.collection)(
|
|
4333
|
+
firestore_default,
|
|
4334
|
+
`users/${userId}/applications/${appId}/builds`
|
|
4203
4335
|
);
|
|
4336
|
+
const constraints = [...addWhereClauses(), (0, import_firestore17.orderBy)("createdAt", "desc")];
|
|
4204
4337
|
if (startAfter) {
|
|
4205
|
-
|
|
4338
|
+
constraints.push((0, import_firestore17.startAfter)(startAfter));
|
|
4206
4339
|
}
|
|
4207
|
-
|
|
4340
|
+
constraints.push((0, import_firestore17.limit)(limit4));
|
|
4341
|
+
const query4 = (0, import_firestore17.query)(buildsCollection, ...constraints);
|
|
4342
|
+
const buildsResult = await (0, import_firestore17.getDocs)(query4);
|
|
4208
4343
|
if (buildsResult.empty) {
|
|
4209
4344
|
return [];
|
|
4210
4345
|
}
|
|
4211
|
-
return buildsResult.docs.map((
|
|
4346
|
+
return buildsResult.docs.map((doc9) => doc9.data());
|
|
4212
4347
|
}
|
|
4213
4348
|
|
|
4214
4349
|
// src/utilities/getRelativeDateFromDateString.ts
|
|
@@ -4510,6 +4645,7 @@ var LogoutCommand_default = LogoutWrapper;
|
|
|
4510
4645
|
// src/components/BuildPicker.tsx
|
|
4511
4646
|
var import_ink29 = require("ink");
|
|
4512
4647
|
var import_react17 = require("react");
|
|
4648
|
+
var import_firestore23 = require("firebase/firestore");
|
|
4513
4649
|
|
|
4514
4650
|
// src/components/SelectTable.tsx
|
|
4515
4651
|
var import_ink28 = require("ink");
|
|
@@ -4575,15 +4711,21 @@ SelectTable.propTypes = {
|
|
|
4575
4711
|
};
|
|
4576
4712
|
var SelectTable_default = SelectTable;
|
|
4577
4713
|
|
|
4714
|
+
// src/utilities/getLatestReleasedBuild.ts
|
|
4715
|
+
var import_firestore21 = require("firebase/firestore");
|
|
4716
|
+
|
|
4578
4717
|
// src/utilities/getBuildById.ts
|
|
4718
|
+
var import_firestore19 = require("firebase/firestore");
|
|
4579
4719
|
async function getBuildById({
|
|
4580
4720
|
appId,
|
|
4581
4721
|
buildId,
|
|
4582
4722
|
userId
|
|
4583
4723
|
}) {
|
|
4584
4724
|
logger_default.debug({ appId, buildId }, "getBuildById");
|
|
4585
|
-
const snapshot = await
|
|
4586
|
-
|
|
4725
|
+
const snapshot = await (0, import_firestore19.getDoc)(
|
|
4726
|
+
(0, import_firestore19.doc)(firestore_default, `users/${userId}/applications/${appId}/builds/${buildId}`)
|
|
4727
|
+
);
|
|
4728
|
+
if (!snapshot.exists()) {
|
|
4587
4729
|
return null;
|
|
4588
4730
|
}
|
|
4589
4731
|
return snapshot.data();
|
|
@@ -4595,21 +4737,26 @@ async function getLatestReleasedBuild({
|
|
|
4595
4737
|
userId
|
|
4596
4738
|
}) {
|
|
4597
4739
|
var _a, _b;
|
|
4598
|
-
const appRef =
|
|
4599
|
-
const appSnapshot = await
|
|
4600
|
-
const
|
|
4601
|
-
if (!
|
|
4740
|
+
const appRef = (0, import_firestore21.doc)(firestore_default, `users/${userId}/applications/${appId}`);
|
|
4741
|
+
const appSnapshot = await (0, import_firestore21.getDoc)(appRef);
|
|
4742
|
+
const app2 = appSnapshot.exists() ? appSnapshot.data() : void 0;
|
|
4743
|
+
if (!app2) {
|
|
4602
4744
|
throw new Error(`Application with ID of ${appId} doesn't exist.`);
|
|
4603
4745
|
}
|
|
4604
|
-
if ((_a =
|
|
4746
|
+
if ((_a = app2.meta) == null ? void 0 : _a.latestReleaseBuildId) {
|
|
4605
4747
|
return await getBuildById({
|
|
4606
|
-
buildId: (_b =
|
|
4748
|
+
buildId: (_b = app2.meta) == null ? void 0 : _b.latestReleaseBuildId,
|
|
4607
4749
|
appId,
|
|
4608
4750
|
userId
|
|
4609
4751
|
}) || void 0;
|
|
4610
4752
|
}
|
|
4611
|
-
const
|
|
4612
|
-
|
|
4753
|
+
const buildsQuery = (0, import_firestore21.query)(
|
|
4754
|
+
(0, import_firestore21.collection)(firestore_default, `users/${userId}/applications/${appId}/builds`),
|
|
4755
|
+
(0, import_firestore21.orderBy)("releasedAt", "desc"),
|
|
4756
|
+
(0, import_firestore21.limit)(1)
|
|
4757
|
+
);
|
|
4758
|
+
const buildsResult = await (0, import_firestore21.getDocs)(buildsQuery);
|
|
4759
|
+
return buildsResult.empty ? void 0 : buildsResult.docs[0].data();
|
|
4613
4760
|
}
|
|
4614
4761
|
|
|
4615
4762
|
// src/components/BuildPicker.tsx
|
|
@@ -4732,7 +4879,7 @@ async function getBuildItems({
|
|
|
4732
4879
|
const { id: userId, label: userName } = await findAppUserId_default(appId);
|
|
4733
4880
|
const latestReleasedBuild = await getLatestReleasedBuild({ appId, userId });
|
|
4734
4881
|
const rawBuilds = await getBuilds({
|
|
4735
|
-
addWhereClauses: (
|
|
4882
|
+
addWhereClauses: () => [(0, import_firestore23.where)("status", "==", "succeeded")],
|
|
4736
4883
|
appId,
|
|
4737
4884
|
limit: 50,
|
|
4738
4885
|
userId
|
|
@@ -4802,7 +4949,7 @@ async function releaseBuild({
|
|
|
4802
4949
|
}
|
|
4803
4950
|
function isFirebaseFunctionError(error) {
|
|
4804
4951
|
return Boolean(
|
|
4805
|
-
typeof error === "object" && error && "code" in error && error.code === "string"
|
|
4952
|
+
typeof error === "object" && error && "code" in error && typeof error.code === "string"
|
|
4806
4953
|
);
|
|
4807
4954
|
}
|
|
4808
4955
|
|
|
@@ -5629,6 +5776,7 @@ async function queueSmokeTest({
|
|
|
5629
5776
|
}
|
|
5630
5777
|
|
|
5631
5778
|
// src/commands/smoke-test/utilities/waitUntilFinished.ts
|
|
5779
|
+
var import_firestore27 = require("firebase/firestore");
|
|
5632
5780
|
async function waitUntilFinished({
|
|
5633
5781
|
appId,
|
|
5634
5782
|
buildId,
|
|
@@ -5636,15 +5784,16 @@ async function waitUntilFinished({
|
|
|
5636
5784
|
userId
|
|
5637
5785
|
}) {
|
|
5638
5786
|
const docPath = `users/${userId}/applications/${appId}/builds/${buildId}`;
|
|
5639
|
-
return new Promise((
|
|
5640
|
-
const unsubscribe =
|
|
5787
|
+
return new Promise((resolve5, reject) => {
|
|
5788
|
+
const unsubscribe = (0, import_firestore27.onSnapshot)(
|
|
5789
|
+
(0, import_firestore27.doc)(firestore_default, docPath),
|
|
5641
5790
|
(snapshot) => {
|
|
5642
|
-
const data = snapshot.exists ? snapshot.data() : void 0;
|
|
5791
|
+
const data = snapshot.exists() ? snapshot.data() : void 0;
|
|
5643
5792
|
const progress = makeProgress(data);
|
|
5644
5793
|
onProgress(progress);
|
|
5645
5794
|
if (progress.isFinished) {
|
|
5646
5795
|
unsubscribe();
|
|
5647
|
-
|
|
5796
|
+
resolve5(progress);
|
|
5648
5797
|
}
|
|
5649
5798
|
},
|
|
5650
5799
|
(err) => {
|
|
@@ -5790,17 +5939,17 @@ var import_ink38 = require("ink");
|
|
|
5790
5939
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
5791
5940
|
var WhoAmI = () => {
|
|
5792
5941
|
const exit = useExit_default();
|
|
5793
|
-
const
|
|
5942
|
+
const auth2 = getAuthConfig();
|
|
5794
5943
|
const { hasAttemptedTracking } = useAnalyticsCommand("whoami", {}, {});
|
|
5795
5944
|
(0, import_react23.useEffect)(() => {
|
|
5796
5945
|
if (hasAttemptedTracking) {
|
|
5797
5946
|
exit();
|
|
5798
5947
|
}
|
|
5799
5948
|
}, [exit, hasAttemptedTracking]);
|
|
5800
|
-
if (!
|
|
5949
|
+
if (!auth2 || !auth2.email) {
|
|
5801
5950
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_ink38.Text, { children: "You're not signed in" });
|
|
5802
5951
|
}
|
|
5803
|
-
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_ink38.Text, { children:
|
|
5952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_ink38.Text, { children: auth2.email });
|
|
5804
5953
|
};
|
|
5805
5954
|
var WhoAmIWrapper = () => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ErrorBoundary_default, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(LoginHOC_default, { isInteractive: false, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(WhoAmI, {}) }) });
|
|
5806
5955
|
var WhoamiCommand_default = WhoAmIWrapper;
|
|
@@ -5843,7 +5992,7 @@ var package_default = {
|
|
|
5843
5992
|
access: "public"
|
|
5844
5993
|
},
|
|
5845
5994
|
name: "@todesktop/cli",
|
|
5846
|
-
version: "1.
|
|
5995
|
+
version: "1.14.0",
|
|
5847
5996
|
license: "MIT",
|
|
5848
5997
|
author: "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
|
|
5849
5998
|
homepage: "https://todesktop.com/cli",
|
|
@@ -5853,21 +6002,23 @@ var package_default = {
|
|
|
5853
6002
|
bin: {
|
|
5854
6003
|
todesktop: "./dist/cli.js"
|
|
5855
6004
|
},
|
|
6005
|
+
types: "./dist/types.d.ts",
|
|
5856
6006
|
engines: {
|
|
5857
|
-
node: ">=
|
|
6007
|
+
node: ">=16"
|
|
5858
6008
|
},
|
|
5859
6009
|
scripts: {
|
|
5860
6010
|
dev: "cp-cli dev.env .env && npm run build:dev && npm link",
|
|
5861
6011
|
"dev:prod": "cp-cli prod.env .env && npm run build && npm link",
|
|
5862
6012
|
"dev:local:prod": "cp-cli prod-local.env .env && npm run build && npm link && cp-cli prod-local.env .env",
|
|
5863
|
-
build: "esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli prod.env .env",
|
|
5864
|
-
"build:dev": "esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli dev.env .env",
|
|
6013
|
+
build: "npm run types:generate && esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli prod.env .env",
|
|
6014
|
+
"build:dev": "npm run types:generate && esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli dev.env .env",
|
|
5865
6015
|
lint: "npm run lint:types && npm run lint:styles",
|
|
5866
6016
|
"lint:styles": "eslint src test .eslintrc.js && prettier --check .",
|
|
5867
6017
|
format: "prettier --write .",
|
|
5868
6018
|
"lint:types": "tsc && tsc-strict",
|
|
5869
6019
|
"lint--fix": "eslint src test --fix",
|
|
5870
6020
|
"docs:generate": "node scripts/generate-readme.js",
|
|
6021
|
+
"types:generate": "node scripts/generate-types.js",
|
|
5871
6022
|
release: "npm run docs:generate && npm run build && npx np --tag=latest",
|
|
5872
6023
|
"release-beta": "npm run docs:generate && npm run build && npx np --any-branch --no-tests --tag=beta",
|
|
5873
6024
|
test: "ava",
|
|
@@ -5900,7 +6051,7 @@ var package_default = {
|
|
|
5900
6051
|
"fast-glob": "^3.2.4",
|
|
5901
6052
|
"final-form": "^4.20.1",
|
|
5902
6053
|
"find-up": "^5.0.0",
|
|
5903
|
-
firebase: "^
|
|
6054
|
+
firebase: "^11.9.1",
|
|
5904
6055
|
"git-rev-sync": "^3.0.2",
|
|
5905
6056
|
ink: "^3.2.0",
|
|
5906
6057
|
"ink-gradient": "^2.0.0",
|
|
@@ -5951,6 +6102,7 @@ var package_default = {
|
|
|
5951
6102
|
"fs-extra": "^9.0.1",
|
|
5952
6103
|
husky: "^4.3.0",
|
|
5953
6104
|
"ink-testing-library": "^2.1.0",
|
|
6105
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
5954
6106
|
"lint-staged": "^10.2.11",
|
|
5955
6107
|
"package-json-type": "^1.0.3",
|
|
5956
6108
|
prettier: "^2.8.1",
|