@ones-open/cli 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +260 -10
- package/dist/index.js +260 -10
- package/dist/types/actions/dev/index.d.ts.map +1 -1
- package/dist/types/actions/dev/types.d.ts +2 -1
- package/dist/types/actions/dev/types.d.ts.map +1 -1
- package/dist/types/actions/logout/index.d.ts.map +1 -1
- package/dist/types/cli/index.d.ts.map +1 -1
- package/dist/types/common/backstage/consts.d.ts +4 -0
- package/dist/types/common/backstage/consts.d.ts.map +1 -0
- package/dist/types/common/backstage/index.d.ts +7 -0
- package/dist/types/common/backstage/index.d.ts.map +1 -0
- package/dist/types/common/backstage/types.d.ts +12 -0
- package/dist/types/common/backstage/types.d.ts.map +1 -0
- package/dist/types/common/backstage/utils.d.ts +3 -0
- package/dist/types/common/backstage/utils.d.ts.map +1 -0
- package/dist/types/common/request/utils.d.ts.map +1 -1
- package/dist/types/common/store/schema.d.ts +58 -0
- package/dist/types/common/store/schema.d.ts.map +1 -1
- package/dist/types/common/store/utils.d.ts +5 -1
- package/dist/types/common/store/utils.d.ts.map +1 -1
- package/dist/types/common/version/consts.d.ts +6 -0
- package/dist/types/common/version/consts.d.ts.map +1 -0
- package/dist/types/common/version/index.d.ts +6 -0
- package/dist/types/common/version/index.d.ts.map +1 -0
- package/dist/types/common/version/task.d.ts +4 -0
- package/dist/types/common/version/task.d.ts.map +1 -0
- package/dist/types/common/version/utils.d.ts +7 -0
- package/dist/types/common/version/utils.d.ts.map +1 -0
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,8 @@ const PKCEChallenge = require("pkce-challenge");
|
|
|
27
27
|
const node_crypto = require("node:crypto");
|
|
28
28
|
const promises = require("node:stream/promises");
|
|
29
29
|
const node_os = require("node:os");
|
|
30
|
+
const boxen = require("boxen");
|
|
31
|
+
const chalk = require("chalk");
|
|
30
32
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
31
33
|
const en = {
|
|
32
34
|
"desc.ones": "ONES CLI/{env}",
|
|
@@ -389,13 +391,23 @@ const StoreONESTokenJSONSchema = zod.z.object({
|
|
|
389
391
|
access_token: zod.z.string().optional(),
|
|
390
392
|
refresh_token: zod.z.string().optional()
|
|
391
393
|
});
|
|
394
|
+
const StoreVersionManagerJSONSchema = zod.z.record(zod.z.object({
|
|
395
|
+
latest_version: zod.z.string().optional(),
|
|
396
|
+
toast_count: zod.z.number().optional()
|
|
397
|
+
}));
|
|
398
|
+
const StoreBackstageManagerJSONSchema = zod.z.object({
|
|
399
|
+
index: zod.z.number().optional(),
|
|
400
|
+
record: zod.z.record(zod.z.number()).optional()
|
|
401
|
+
});
|
|
392
402
|
const StoreJSONSchema = zod.z.object({
|
|
393
403
|
version: zod.z.string().optional(),
|
|
394
404
|
timestamp: zod.z.number().optional(),
|
|
395
405
|
base_url: zod.z.string().optional(),
|
|
396
406
|
region_url: zod.z.string().optional(),
|
|
397
407
|
host_token: zod.z.string().optional(),
|
|
398
|
-
ones_token: StoreONESTokenJSONSchema.optional()
|
|
408
|
+
ones_token: StoreONESTokenJSONSchema.optional(),
|
|
409
|
+
version_manager: StoreVersionManagerJSONSchema.optional(),
|
|
410
|
+
backstage_manager: StoreBackstageManagerJSONSchema.optional()
|
|
399
411
|
});
|
|
400
412
|
const {
|
|
401
413
|
ensureFile,
|
|
@@ -490,6 +502,26 @@ const setHostToken = async (token) => {
|
|
|
490
502
|
host_token: token
|
|
491
503
|
});
|
|
492
504
|
};
|
|
505
|
+
const getVersionManager = async () => {
|
|
506
|
+
var _store$version_manage;
|
|
507
|
+
const store = await getStore();
|
|
508
|
+
return (_store$version_manage = store.version_manager) !== null && _store$version_manage !== void 0 ? _store$version_manage : {};
|
|
509
|
+
};
|
|
510
|
+
const setVersionManager = async (versionManager) => {
|
|
511
|
+
return mergeStore({
|
|
512
|
+
version_manager: versionManager
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
const getBackstageManager = async () => {
|
|
516
|
+
var _store$backstage_mana;
|
|
517
|
+
const store = await getStore();
|
|
518
|
+
return (_store$backstage_mana = store.backstage_manager) !== null && _store$backstage_mana !== void 0 ? _store$backstage_mana : {};
|
|
519
|
+
};
|
|
520
|
+
const setBackstageManager = async (backstageManager) => {
|
|
521
|
+
return mergeStore({
|
|
522
|
+
backstage_manager: backstageManager
|
|
523
|
+
});
|
|
524
|
+
};
|
|
493
525
|
const API = {
|
|
494
526
|
TOKEN_INFO: "/project/api/project/auth/token_info",
|
|
495
527
|
HOSTED_TOKEN: "/platform/runtime_manager/hosted_token",
|
|
@@ -527,8 +559,13 @@ const consoleAppNotInstalledMessage = () => {
|
|
|
527
559
|
const getURL = async (path, pathMap, queryMap) => {
|
|
528
560
|
const base = await getRegionURL();
|
|
529
561
|
if (base) {
|
|
562
|
+
let baseString = base;
|
|
563
|
+
const pathString = getPath(path, pathMap !== null && pathMap !== void 0 ? pathMap : {});
|
|
564
|
+
if (baseString.endsWith("/") && pathString.startsWith("/")) {
|
|
565
|
+
baseString = baseString.slice(0, -1);
|
|
566
|
+
}
|
|
530
567
|
const query = new URLSearchParams(queryMap !== null && queryMap !== void 0 ? queryMap : {}).toString();
|
|
531
|
-
return `${
|
|
568
|
+
return `${baseString}${pathString}${query ? `?${query}` : ""}`;
|
|
532
569
|
}
|
|
533
570
|
consoleUnauthorizedMessage();
|
|
534
571
|
};
|
|
@@ -1451,7 +1488,8 @@ const dev = async function() {
|
|
|
1451
1488
|
ONES_DEV_WEB_SERVER_PORT: `${ONES_DEV_WEB_SERVER_PORT}`,
|
|
1452
1489
|
ONES_HOSTED_TOKEN: "",
|
|
1453
1490
|
ONES_HOSTED_APP_ID: "",
|
|
1454
|
-
|
|
1491
|
+
ONES_HOSTED_APP_BASE_URL: "",
|
|
1492
|
+
ONES_HOSTED_MANAGER_BASE_URL: ""
|
|
1455
1493
|
};
|
|
1456
1494
|
const cancelWaiting = startWaiting();
|
|
1457
1495
|
let enableTunnel = true;
|
|
@@ -1470,10 +1508,12 @@ const dev = async function() {
|
|
|
1470
1508
|
const regionURL = await getRegionURL();
|
|
1471
1509
|
const ONES_HOSTED_TOKEN = await getHostToken();
|
|
1472
1510
|
const ONES_HOSTED_APP_ID = appID;
|
|
1473
|
-
const
|
|
1511
|
+
const ONES_HOSTED_MANAGER_BASE_URL = `${regionURL}/platform/runtime_manager`;
|
|
1512
|
+
const ONES_HOSTED_APP_BASE_URL = await buildTunnelUrl();
|
|
1474
1513
|
env2.ONES_HOSTED_TOKEN = ONES_HOSTED_TOKEN;
|
|
1475
1514
|
env2.ONES_HOSTED_APP_ID = ONES_HOSTED_APP_ID;
|
|
1476
|
-
env2.
|
|
1515
|
+
env2.ONES_HOSTED_APP_BASE_URL = ONES_HOSTED_APP_BASE_URL;
|
|
1516
|
+
env2.ONES_HOSTED_MANAGER_BASE_URL = ONES_HOSTED_MANAGER_BASE_URL;
|
|
1477
1517
|
} else {
|
|
1478
1518
|
console.log("Not logged in or token invalid, skipping tunnel connection...");
|
|
1479
1519
|
}
|
|
@@ -1829,7 +1869,12 @@ const logout = async function() {
|
|
|
1829
1869
|
} = createOnesApp.getCommandOptions(args, logoutCommandArguments);
|
|
1830
1870
|
const normalizedOptions = await normalize$7(options);
|
|
1831
1871
|
lodashEs.noop(normalizedOptions);
|
|
1832
|
-
await
|
|
1872
|
+
await mergeStore({
|
|
1873
|
+
base_url: "",
|
|
1874
|
+
region_url: "",
|
|
1875
|
+
host_token: "",
|
|
1876
|
+
ones_token: {}
|
|
1877
|
+
});
|
|
1833
1878
|
console.log("Logged out successfully!");
|
|
1834
1879
|
};
|
|
1835
1880
|
const normalize$6 = async (options) => {
|
|
@@ -2405,8 +2450,210 @@ const $legacy = new commander.Command("legacy").description(i18n.t("desc.legacy"
|
|
|
2405
2450
|
$legacy.addCommand($create);
|
|
2406
2451
|
createOnesApp.addCommandUsage($legacy);
|
|
2407
2452
|
createOnesApp.addCommandOutput($legacy);
|
|
2453
|
+
var VERSION_COMPARE_RESULT = /* @__PURE__ */ ((VERSION_COMPARE_RESULT2) => {
|
|
2454
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["LESS_THAN"] = -1] = "LESS_THAN";
|
|
2455
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["EQUAL"] = 0] = "EQUAL";
|
|
2456
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["GREATER_THAN"] = 1] = "GREATER_THAN";
|
|
2457
|
+
return VERSION_COMPARE_RESULT2;
|
|
2458
|
+
})(VERSION_COMPARE_RESULT || {});
|
|
2459
|
+
const fetchLatestVersion = (packageName2) => {
|
|
2460
|
+
const {
|
|
2461
|
+
promise,
|
|
2462
|
+
resolve
|
|
2463
|
+
} = createPromise();
|
|
2464
|
+
const child = node_child_process.spawn("npm", ["view", packageName2, "version"], {
|
|
2465
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2466
|
+
});
|
|
2467
|
+
let stdout = "";
|
|
2468
|
+
child.stdout.on("data", (chunk) => {
|
|
2469
|
+
stdout += chunk.toString();
|
|
2470
|
+
});
|
|
2471
|
+
let running = true;
|
|
2472
|
+
child.on("close", (code) => {
|
|
2473
|
+
running = false;
|
|
2474
|
+
if (code !== 0) {
|
|
2475
|
+
resolve("");
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
resolve(stdout.trim());
|
|
2479
|
+
});
|
|
2480
|
+
child.on("error", () => {
|
|
2481
|
+
running = false;
|
|
2482
|
+
resolve("");
|
|
2483
|
+
});
|
|
2484
|
+
promise.then(() => {
|
|
2485
|
+
if (running) {
|
|
2486
|
+
child.kill();
|
|
2487
|
+
}
|
|
2488
|
+
});
|
|
2489
|
+
return {
|
|
2490
|
+
promise,
|
|
2491
|
+
resolve
|
|
2492
|
+
};
|
|
2493
|
+
};
|
|
2494
|
+
const compareVersion = (version1, version2) => {
|
|
2495
|
+
if (/[^0-9.]/.test(version1)) {
|
|
2496
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2497
|
+
}
|
|
2498
|
+
if (/[^0-9.]/.test(version2)) {
|
|
2499
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2500
|
+
}
|
|
2501
|
+
const [major1 = "0", minor1 = "0", patch1 = "0", rest1 = ""] = version1.split(".");
|
|
2502
|
+
const [major2 = "0", minor2 = "0", patch2 = "0", rest2 = ""] = version2.split(".");
|
|
2503
|
+
if (rest1 || rest2) {
|
|
2504
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2505
|
+
}
|
|
2506
|
+
const length1 = Math.max(major1.length, minor1.length, patch1.length);
|
|
2507
|
+
const length2 = Math.max(major2.length, minor2.length, patch2.length);
|
|
2508
|
+
const maxLength = Math.max(length1, length2);
|
|
2509
|
+
const major1String = major1.padStart(maxLength, "0");
|
|
2510
|
+
const major2String = major2.padStart(maxLength, "0");
|
|
2511
|
+
const minor1String = minor1.padStart(maxLength, "0");
|
|
2512
|
+
const minor2String = minor2.padStart(maxLength, "0");
|
|
2513
|
+
const patch1String = patch1.padStart(maxLength, "0");
|
|
2514
|
+
const patch2String = patch2.padStart(maxLength, "0");
|
|
2515
|
+
const version1String = `${major1String}${minor1String}${patch1String}`;
|
|
2516
|
+
const version2String = `${major2String}${minor2String}${patch2String}`;
|
|
2517
|
+
if (version1String === version2String) {
|
|
2518
|
+
return VERSION_COMPARE_RESULT.EQUAL;
|
|
2519
|
+
}
|
|
2520
|
+
if (version1String > version2String) {
|
|
2521
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2522
|
+
}
|
|
2523
|
+
return VERSION_COMPARE_RESULT.LESS_THAN;
|
|
2524
|
+
};
|
|
2525
|
+
const COOL_DOWN_MS = {
|
|
2526
|
+
ONE_DAY: 1e3 * 60 * 60 * 24
|
|
2527
|
+
};
|
|
2528
|
+
var _packageJSON$name, _packageJSON$version;
|
|
2529
|
+
const packageJSON$1 = getPackageJSON();
|
|
2530
|
+
const packageName = (_packageJSON$name = packageJSON$1.name) !== null && _packageJSON$name !== void 0 ? _packageJSON$name : "";
|
|
2531
|
+
const currentVersion = (_packageJSON$version = packageJSON$1.version) !== null && _packageJSON$version !== void 0 ? _packageJSON$version : "";
|
|
2532
|
+
const fetchLatestVersionTask = {
|
|
2533
|
+
name: "fetchLatestVersionTask",
|
|
2534
|
+
cool_down: COOL_DOWN_MS.ONE_DAY,
|
|
2535
|
+
invoke: () => {
|
|
2536
|
+
const {
|
|
2537
|
+
promise,
|
|
2538
|
+
resolve
|
|
2539
|
+
} = fetchLatestVersion(packageName);
|
|
2540
|
+
const throttle = sleep(1e3);
|
|
2541
|
+
return {
|
|
2542
|
+
finish: async () => {
|
|
2543
|
+
await throttle;
|
|
2544
|
+
resolve("");
|
|
2545
|
+
await promise.then(async (nextLatestVersion) => {
|
|
2546
|
+
if (nextLatestVersion) {
|
|
2547
|
+
if (nextLatestVersion !== currentVersion) {
|
|
2548
|
+
var _versionManager$packa, _record$latest_versio;
|
|
2549
|
+
const versionManager = await getVersionManager();
|
|
2550
|
+
const record = (_versionManager$packa = versionManager[packageName]) !== null && _versionManager$packa !== void 0 ? _versionManager$packa : {};
|
|
2551
|
+
const latestVersion = (_record$latest_versio = record.latest_version) !== null && _record$latest_versio !== void 0 ? _record$latest_versio : "";
|
|
2552
|
+
if (nextLatestVersion !== latestVersion) {
|
|
2553
|
+
await setVersionManager(lodashEs.merge(versionManager, {
|
|
2554
|
+
[packageName]: {
|
|
2555
|
+
latest_version: nextLatestVersion,
|
|
2556
|
+
toast_count: 0
|
|
2557
|
+
}
|
|
2558
|
+
}));
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
const TOAST_COUNT_MAX = 3;
|
|
2568
|
+
const toastLatestVersionTask = {
|
|
2569
|
+
name: "toastLatestVersionTask",
|
|
2570
|
+
cool_down: COOL_DOWN_MS.ONE_DAY,
|
|
2571
|
+
invoke: () => {
|
|
2572
|
+
return {
|
|
2573
|
+
finish: async () => {
|
|
2574
|
+
const versionManager = await getVersionManager();
|
|
2575
|
+
const record = versionManager[packageName];
|
|
2576
|
+
if (record) {
|
|
2577
|
+
var _record$toast_count, _record$latest_versio2;
|
|
2578
|
+
const toastCount = (_record$toast_count = record.toast_count) !== null && _record$toast_count !== void 0 ? _record$toast_count : 0;
|
|
2579
|
+
const latestVersion = (_record$latest_versio2 = record.latest_version) !== null && _record$latest_versio2 !== void 0 ? _record$latest_versio2 : "";
|
|
2580
|
+
if (toastCount < TOAST_COUNT_MAX) {
|
|
2581
|
+
const compareResult = compareVersion(latestVersion, currentVersion);
|
|
2582
|
+
if (compareResult === VERSION_COMPARE_RESULT.GREATER_THAN) {
|
|
2583
|
+
const command = `npm install -g ${packageName}`;
|
|
2584
|
+
const message = [`A new version of ${chalk.yellow(packageName)} is available: ${chalk.yellow(latestVersion)}`, `Run ${chalk.yellow(command)} to update.`].join("\n");
|
|
2585
|
+
const result = boxen(message, {
|
|
2586
|
+
padding: 1,
|
|
2587
|
+
margin: 1,
|
|
2588
|
+
borderStyle: "round",
|
|
2589
|
+
borderColor: "yellow",
|
|
2590
|
+
title: `${packageName}`,
|
|
2591
|
+
titleAlignment: "center"
|
|
2592
|
+
});
|
|
2593
|
+
console.log(result);
|
|
2594
|
+
await setVersionManager(lodashEs.merge(versionManager, {
|
|
2595
|
+
[packageName]: {
|
|
2596
|
+
toast_count: toastCount + 1
|
|
2597
|
+
}
|
|
2598
|
+
}));
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
};
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
const taskItems = [fetchLatestVersionTask, toastLatestVersionTask];
|
|
2607
|
+
const invokeBackstage = async () => {
|
|
2608
|
+
let taskResult = null;
|
|
2609
|
+
const result = {
|
|
2610
|
+
finish: async () => {
|
|
2611
|
+
if (taskResult) {
|
|
2612
|
+
try {
|
|
2613
|
+
return await taskResult.finish();
|
|
2614
|
+
} catch (error) {
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
return Promise.resolve();
|
|
2618
|
+
}
|
|
2619
|
+
};
|
|
2620
|
+
try {
|
|
2621
|
+
var _manager$index, _manager$record;
|
|
2622
|
+
const manager = await getBackstageManager();
|
|
2623
|
+
const index = (_manager$index = manager.index) !== null && _manager$index !== void 0 ? _manager$index : 0;
|
|
2624
|
+
const record = (_manager$record = manager.record) !== null && _manager$record !== void 0 ? _manager$record : {};
|
|
2625
|
+
if (taskItems.length > 0) {
|
|
2626
|
+
var _currentTask$name, _currentTask$cool_dow;
|
|
2627
|
+
let next = {
|
|
2628
|
+
index: index + 1
|
|
2629
|
+
};
|
|
2630
|
+
const currentTaskIndex = index % taskItems.length;
|
|
2631
|
+
const currentTask = taskItems[currentTaskIndex];
|
|
2632
|
+
const currentTaskName = (_currentTask$name = currentTask === null || currentTask === void 0 ? void 0 : currentTask.name) !== null && _currentTask$name !== void 0 ? _currentTask$name : "";
|
|
2633
|
+
const currentTaskCoolDown = (_currentTask$cool_dow = currentTask === null || currentTask === void 0 ? void 0 : currentTask.cool_down) !== null && _currentTask$cool_dow !== void 0 ? _currentTask$cool_dow : 0;
|
|
2634
|
+
if (currentTaskName && currentTaskCoolDown) {
|
|
2635
|
+
var _record$currentTaskNa;
|
|
2636
|
+
const lastRun = (_record$currentTaskNa = record[currentTaskName]) !== null && _record$currentTaskNa !== void 0 ? _record$currentTaskNa : 0;
|
|
2637
|
+
const now = Date.now();
|
|
2638
|
+
const shouldRun = now > lastRun + currentTaskCoolDown;
|
|
2639
|
+
if (shouldRun) {
|
|
2640
|
+
taskResult = currentTask.invoke();
|
|
2641
|
+
next = lodashEs.merge(next, {
|
|
2642
|
+
record: lodashEs.merge(record, {
|
|
2643
|
+
[currentTaskName]: now
|
|
2644
|
+
})
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
await setBackstageManager(lodashEs.merge(manager, next));
|
|
2649
|
+
}
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
}
|
|
2652
|
+
return result;
|
|
2653
|
+
};
|
|
2408
2654
|
const ones = new commander.Command("ones");
|
|
2409
|
-
const
|
|
2655
|
+
const packageJSON = getPackageJSON();
|
|
2656
|
+
const version = `${packageJSON.version}`;
|
|
2410
2657
|
const env = `${version} Node/${process.version}`;
|
|
2411
2658
|
ones.description(i18n.t("desc.ones", {
|
|
2412
2659
|
env
|
|
@@ -2423,8 +2670,11 @@ createOnesApp.addCommandOutput(ones);
|
|
|
2423
2670
|
const runCommandONES = async () => {
|
|
2424
2671
|
const command = ones;
|
|
2425
2672
|
createOnesApp.setContext("command", command);
|
|
2426
|
-
const
|
|
2427
|
-
|
|
2428
|
-
await
|
|
2673
|
+
const {
|
|
2674
|
+
finish
|
|
2675
|
+
} = await invokeBackstage();
|
|
2676
|
+
command.version(version, "-v, --version");
|
|
2677
|
+
await command.parseAsync();
|
|
2678
|
+
await finish();
|
|
2429
2679
|
};
|
|
2430
2680
|
exports.runCommandONES = runCommandONES;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,8 @@ import PKCEChallenge from "pkce-challenge";
|
|
|
25
25
|
import { createHash } from "node:crypto";
|
|
26
26
|
import { pipeline } from "node:stream/promises";
|
|
27
27
|
import { homedir } from "node:os";
|
|
28
|
+
import boxen from "boxen";
|
|
29
|
+
import chalk from "chalk";
|
|
28
30
|
const en = {
|
|
29
31
|
"desc.ones": "ONES CLI/{env}",
|
|
30
32
|
"desc.build": "Build your ONES App",
|
|
@@ -386,13 +388,23 @@ const StoreONESTokenJSONSchema = z.object({
|
|
|
386
388
|
access_token: z.string().optional(),
|
|
387
389
|
refresh_token: z.string().optional()
|
|
388
390
|
});
|
|
391
|
+
const StoreVersionManagerJSONSchema = z.record(z.object({
|
|
392
|
+
latest_version: z.string().optional(),
|
|
393
|
+
toast_count: z.number().optional()
|
|
394
|
+
}));
|
|
395
|
+
const StoreBackstageManagerJSONSchema = z.object({
|
|
396
|
+
index: z.number().optional(),
|
|
397
|
+
record: z.record(z.number()).optional()
|
|
398
|
+
});
|
|
389
399
|
const StoreJSONSchema = z.object({
|
|
390
400
|
version: z.string().optional(),
|
|
391
401
|
timestamp: z.number().optional(),
|
|
392
402
|
base_url: z.string().optional(),
|
|
393
403
|
region_url: z.string().optional(),
|
|
394
404
|
host_token: z.string().optional(),
|
|
395
|
-
ones_token: StoreONESTokenJSONSchema.optional()
|
|
405
|
+
ones_token: StoreONESTokenJSONSchema.optional(),
|
|
406
|
+
version_manager: StoreVersionManagerJSONSchema.optional(),
|
|
407
|
+
backstage_manager: StoreBackstageManagerJSONSchema.optional()
|
|
396
408
|
});
|
|
397
409
|
const {
|
|
398
410
|
ensureFile,
|
|
@@ -487,6 +499,26 @@ const setHostToken = async (token) => {
|
|
|
487
499
|
host_token: token
|
|
488
500
|
});
|
|
489
501
|
};
|
|
502
|
+
const getVersionManager = async () => {
|
|
503
|
+
var _store$version_manage;
|
|
504
|
+
const store = await getStore();
|
|
505
|
+
return (_store$version_manage = store.version_manager) !== null && _store$version_manage !== void 0 ? _store$version_manage : {};
|
|
506
|
+
};
|
|
507
|
+
const setVersionManager = async (versionManager) => {
|
|
508
|
+
return mergeStore({
|
|
509
|
+
version_manager: versionManager
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
const getBackstageManager = async () => {
|
|
513
|
+
var _store$backstage_mana;
|
|
514
|
+
const store = await getStore();
|
|
515
|
+
return (_store$backstage_mana = store.backstage_manager) !== null && _store$backstage_mana !== void 0 ? _store$backstage_mana : {};
|
|
516
|
+
};
|
|
517
|
+
const setBackstageManager = async (backstageManager) => {
|
|
518
|
+
return mergeStore({
|
|
519
|
+
backstage_manager: backstageManager
|
|
520
|
+
});
|
|
521
|
+
};
|
|
490
522
|
const API = {
|
|
491
523
|
TOKEN_INFO: "/project/api/project/auth/token_info",
|
|
492
524
|
HOSTED_TOKEN: "/platform/runtime_manager/hosted_token",
|
|
@@ -524,8 +556,13 @@ const consoleAppNotInstalledMessage = () => {
|
|
|
524
556
|
const getURL = async (path, pathMap, queryMap) => {
|
|
525
557
|
const base = await getRegionURL();
|
|
526
558
|
if (base) {
|
|
559
|
+
let baseString = base;
|
|
560
|
+
const pathString = getPath(path, pathMap !== null && pathMap !== void 0 ? pathMap : {});
|
|
561
|
+
if (baseString.endsWith("/") && pathString.startsWith("/")) {
|
|
562
|
+
baseString = baseString.slice(0, -1);
|
|
563
|
+
}
|
|
527
564
|
const query = new URLSearchParams(queryMap !== null && queryMap !== void 0 ? queryMap : {}).toString();
|
|
528
|
-
return `${
|
|
565
|
+
return `${baseString}${pathString}${query ? `?${query}` : ""}`;
|
|
529
566
|
}
|
|
530
567
|
consoleUnauthorizedMessage();
|
|
531
568
|
};
|
|
@@ -1448,7 +1485,8 @@ const dev = async function() {
|
|
|
1448
1485
|
ONES_DEV_WEB_SERVER_PORT: `${ONES_DEV_WEB_SERVER_PORT}`,
|
|
1449
1486
|
ONES_HOSTED_TOKEN: "",
|
|
1450
1487
|
ONES_HOSTED_APP_ID: "",
|
|
1451
|
-
|
|
1488
|
+
ONES_HOSTED_APP_BASE_URL: "",
|
|
1489
|
+
ONES_HOSTED_MANAGER_BASE_URL: ""
|
|
1452
1490
|
};
|
|
1453
1491
|
const cancelWaiting = startWaiting();
|
|
1454
1492
|
let enableTunnel = true;
|
|
@@ -1467,10 +1505,12 @@ const dev = async function() {
|
|
|
1467
1505
|
const regionURL = await getRegionURL();
|
|
1468
1506
|
const ONES_HOSTED_TOKEN = await getHostToken();
|
|
1469
1507
|
const ONES_HOSTED_APP_ID = appID;
|
|
1470
|
-
const
|
|
1508
|
+
const ONES_HOSTED_MANAGER_BASE_URL = `${regionURL}/platform/runtime_manager`;
|
|
1509
|
+
const ONES_HOSTED_APP_BASE_URL = await buildTunnelUrl();
|
|
1471
1510
|
env2.ONES_HOSTED_TOKEN = ONES_HOSTED_TOKEN;
|
|
1472
1511
|
env2.ONES_HOSTED_APP_ID = ONES_HOSTED_APP_ID;
|
|
1473
|
-
env2.
|
|
1512
|
+
env2.ONES_HOSTED_APP_BASE_URL = ONES_HOSTED_APP_BASE_URL;
|
|
1513
|
+
env2.ONES_HOSTED_MANAGER_BASE_URL = ONES_HOSTED_MANAGER_BASE_URL;
|
|
1474
1514
|
} else {
|
|
1475
1515
|
console.log("Not logged in or token invalid, skipping tunnel connection...");
|
|
1476
1516
|
}
|
|
@@ -1826,7 +1866,12 @@ const logout = async function() {
|
|
|
1826
1866
|
} = getCommandOptions(args, logoutCommandArguments);
|
|
1827
1867
|
const normalizedOptions = await normalize$7(options);
|
|
1828
1868
|
noop(normalizedOptions);
|
|
1829
|
-
await
|
|
1869
|
+
await mergeStore({
|
|
1870
|
+
base_url: "",
|
|
1871
|
+
region_url: "",
|
|
1872
|
+
host_token: "",
|
|
1873
|
+
ones_token: {}
|
|
1874
|
+
});
|
|
1830
1875
|
console.log("Logged out successfully!");
|
|
1831
1876
|
};
|
|
1832
1877
|
const normalize$6 = async (options) => {
|
|
@@ -2402,8 +2447,210 @@ const $legacy = new Command("legacy").description(i18n.t("desc.legacy"));
|
|
|
2402
2447
|
$legacy.addCommand($create);
|
|
2403
2448
|
addCommandUsage($legacy);
|
|
2404
2449
|
addCommandOutput($legacy);
|
|
2450
|
+
var VERSION_COMPARE_RESULT = /* @__PURE__ */ ((VERSION_COMPARE_RESULT2) => {
|
|
2451
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["LESS_THAN"] = -1] = "LESS_THAN";
|
|
2452
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["EQUAL"] = 0] = "EQUAL";
|
|
2453
|
+
VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["GREATER_THAN"] = 1] = "GREATER_THAN";
|
|
2454
|
+
return VERSION_COMPARE_RESULT2;
|
|
2455
|
+
})(VERSION_COMPARE_RESULT || {});
|
|
2456
|
+
const fetchLatestVersion = (packageName2) => {
|
|
2457
|
+
const {
|
|
2458
|
+
promise,
|
|
2459
|
+
resolve: resolve2
|
|
2460
|
+
} = createPromise();
|
|
2461
|
+
const child = spawn("npm", ["view", packageName2, "version"], {
|
|
2462
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2463
|
+
});
|
|
2464
|
+
let stdout = "";
|
|
2465
|
+
child.stdout.on("data", (chunk) => {
|
|
2466
|
+
stdout += chunk.toString();
|
|
2467
|
+
});
|
|
2468
|
+
let running = true;
|
|
2469
|
+
child.on("close", (code) => {
|
|
2470
|
+
running = false;
|
|
2471
|
+
if (code !== 0) {
|
|
2472
|
+
resolve2("");
|
|
2473
|
+
return;
|
|
2474
|
+
}
|
|
2475
|
+
resolve2(stdout.trim());
|
|
2476
|
+
});
|
|
2477
|
+
child.on("error", () => {
|
|
2478
|
+
running = false;
|
|
2479
|
+
resolve2("");
|
|
2480
|
+
});
|
|
2481
|
+
promise.then(() => {
|
|
2482
|
+
if (running) {
|
|
2483
|
+
child.kill();
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2486
|
+
return {
|
|
2487
|
+
promise,
|
|
2488
|
+
resolve: resolve2
|
|
2489
|
+
};
|
|
2490
|
+
};
|
|
2491
|
+
const compareVersion = (version1, version2) => {
|
|
2492
|
+
if (/[^0-9.]/.test(version1)) {
|
|
2493
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2494
|
+
}
|
|
2495
|
+
if (/[^0-9.]/.test(version2)) {
|
|
2496
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2497
|
+
}
|
|
2498
|
+
const [major1 = "0", minor1 = "0", patch1 = "0", rest1 = ""] = version1.split(".");
|
|
2499
|
+
const [major2 = "0", minor2 = "0", patch2 = "0", rest2 = ""] = version2.split(".");
|
|
2500
|
+
if (rest1 || rest2) {
|
|
2501
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2502
|
+
}
|
|
2503
|
+
const length1 = Math.max(major1.length, minor1.length, patch1.length);
|
|
2504
|
+
const length2 = Math.max(major2.length, minor2.length, patch2.length);
|
|
2505
|
+
const maxLength = Math.max(length1, length2);
|
|
2506
|
+
const major1String = major1.padStart(maxLength, "0");
|
|
2507
|
+
const major2String = major2.padStart(maxLength, "0");
|
|
2508
|
+
const minor1String = minor1.padStart(maxLength, "0");
|
|
2509
|
+
const minor2String = minor2.padStart(maxLength, "0");
|
|
2510
|
+
const patch1String = patch1.padStart(maxLength, "0");
|
|
2511
|
+
const patch2String = patch2.padStart(maxLength, "0");
|
|
2512
|
+
const version1String = `${major1String}${minor1String}${patch1String}`;
|
|
2513
|
+
const version2String = `${major2String}${minor2String}${patch2String}`;
|
|
2514
|
+
if (version1String === version2String) {
|
|
2515
|
+
return VERSION_COMPARE_RESULT.EQUAL;
|
|
2516
|
+
}
|
|
2517
|
+
if (version1String > version2String) {
|
|
2518
|
+
return VERSION_COMPARE_RESULT.GREATER_THAN;
|
|
2519
|
+
}
|
|
2520
|
+
return VERSION_COMPARE_RESULT.LESS_THAN;
|
|
2521
|
+
};
|
|
2522
|
+
const COOL_DOWN_MS = {
|
|
2523
|
+
ONE_DAY: 1e3 * 60 * 60 * 24
|
|
2524
|
+
};
|
|
2525
|
+
var _packageJSON$name, _packageJSON$version;
|
|
2526
|
+
const packageJSON$1 = getPackageJSON();
|
|
2527
|
+
const packageName = (_packageJSON$name = packageJSON$1.name) !== null && _packageJSON$name !== void 0 ? _packageJSON$name : "";
|
|
2528
|
+
const currentVersion = (_packageJSON$version = packageJSON$1.version) !== null && _packageJSON$version !== void 0 ? _packageJSON$version : "";
|
|
2529
|
+
const fetchLatestVersionTask = {
|
|
2530
|
+
name: "fetchLatestVersionTask",
|
|
2531
|
+
cool_down: COOL_DOWN_MS.ONE_DAY,
|
|
2532
|
+
invoke: () => {
|
|
2533
|
+
const {
|
|
2534
|
+
promise,
|
|
2535
|
+
resolve: resolve2
|
|
2536
|
+
} = fetchLatestVersion(packageName);
|
|
2537
|
+
const throttle = sleep(1e3);
|
|
2538
|
+
return {
|
|
2539
|
+
finish: async () => {
|
|
2540
|
+
await throttle;
|
|
2541
|
+
resolve2("");
|
|
2542
|
+
await promise.then(async (nextLatestVersion) => {
|
|
2543
|
+
if (nextLatestVersion) {
|
|
2544
|
+
if (nextLatestVersion !== currentVersion) {
|
|
2545
|
+
var _versionManager$packa, _record$latest_versio;
|
|
2546
|
+
const versionManager = await getVersionManager();
|
|
2547
|
+
const record = (_versionManager$packa = versionManager[packageName]) !== null && _versionManager$packa !== void 0 ? _versionManager$packa : {};
|
|
2548
|
+
const latestVersion = (_record$latest_versio = record.latest_version) !== null && _record$latest_versio !== void 0 ? _record$latest_versio : "";
|
|
2549
|
+
if (nextLatestVersion !== latestVersion) {
|
|
2550
|
+
await setVersionManager(merge(versionManager, {
|
|
2551
|
+
[packageName]: {
|
|
2552
|
+
latest_version: nextLatestVersion,
|
|
2553
|
+
toast_count: 0
|
|
2554
|
+
}
|
|
2555
|
+
}));
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
};
|
|
2564
|
+
const TOAST_COUNT_MAX = 3;
|
|
2565
|
+
const toastLatestVersionTask = {
|
|
2566
|
+
name: "toastLatestVersionTask",
|
|
2567
|
+
cool_down: COOL_DOWN_MS.ONE_DAY,
|
|
2568
|
+
invoke: () => {
|
|
2569
|
+
return {
|
|
2570
|
+
finish: async () => {
|
|
2571
|
+
const versionManager = await getVersionManager();
|
|
2572
|
+
const record = versionManager[packageName];
|
|
2573
|
+
if (record) {
|
|
2574
|
+
var _record$toast_count, _record$latest_versio2;
|
|
2575
|
+
const toastCount = (_record$toast_count = record.toast_count) !== null && _record$toast_count !== void 0 ? _record$toast_count : 0;
|
|
2576
|
+
const latestVersion = (_record$latest_versio2 = record.latest_version) !== null && _record$latest_versio2 !== void 0 ? _record$latest_versio2 : "";
|
|
2577
|
+
if (toastCount < TOAST_COUNT_MAX) {
|
|
2578
|
+
const compareResult = compareVersion(latestVersion, currentVersion);
|
|
2579
|
+
if (compareResult === VERSION_COMPARE_RESULT.GREATER_THAN) {
|
|
2580
|
+
const command = `npm install -g ${packageName}`;
|
|
2581
|
+
const message = [`A new version of ${chalk.yellow(packageName)} is available: ${chalk.yellow(latestVersion)}`, `Run ${chalk.yellow(command)} to update.`].join("\n");
|
|
2582
|
+
const result = boxen(message, {
|
|
2583
|
+
padding: 1,
|
|
2584
|
+
margin: 1,
|
|
2585
|
+
borderStyle: "round",
|
|
2586
|
+
borderColor: "yellow",
|
|
2587
|
+
title: `${packageName}`,
|
|
2588
|
+
titleAlignment: "center"
|
|
2589
|
+
});
|
|
2590
|
+
console.log(result);
|
|
2591
|
+
await setVersionManager(merge(versionManager, {
|
|
2592
|
+
[packageName]: {
|
|
2593
|
+
toast_count: toastCount + 1
|
|
2594
|
+
}
|
|
2595
|
+
}));
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
const taskItems = [fetchLatestVersionTask, toastLatestVersionTask];
|
|
2604
|
+
const invokeBackstage = async () => {
|
|
2605
|
+
let taskResult = null;
|
|
2606
|
+
const result = {
|
|
2607
|
+
finish: async () => {
|
|
2608
|
+
if (taskResult) {
|
|
2609
|
+
try {
|
|
2610
|
+
return await taskResult.finish();
|
|
2611
|
+
} catch (error) {
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
return Promise.resolve();
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
try {
|
|
2618
|
+
var _manager$index, _manager$record;
|
|
2619
|
+
const manager = await getBackstageManager();
|
|
2620
|
+
const index = (_manager$index = manager.index) !== null && _manager$index !== void 0 ? _manager$index : 0;
|
|
2621
|
+
const record = (_manager$record = manager.record) !== null && _manager$record !== void 0 ? _manager$record : {};
|
|
2622
|
+
if (taskItems.length > 0) {
|
|
2623
|
+
var _currentTask$name, _currentTask$cool_dow;
|
|
2624
|
+
let next = {
|
|
2625
|
+
index: index + 1
|
|
2626
|
+
};
|
|
2627
|
+
const currentTaskIndex = index % taskItems.length;
|
|
2628
|
+
const currentTask = taskItems[currentTaskIndex];
|
|
2629
|
+
const currentTaskName = (_currentTask$name = currentTask === null || currentTask === void 0 ? void 0 : currentTask.name) !== null && _currentTask$name !== void 0 ? _currentTask$name : "";
|
|
2630
|
+
const currentTaskCoolDown = (_currentTask$cool_dow = currentTask === null || currentTask === void 0 ? void 0 : currentTask.cool_down) !== null && _currentTask$cool_dow !== void 0 ? _currentTask$cool_dow : 0;
|
|
2631
|
+
if (currentTaskName && currentTaskCoolDown) {
|
|
2632
|
+
var _record$currentTaskNa;
|
|
2633
|
+
const lastRun = (_record$currentTaskNa = record[currentTaskName]) !== null && _record$currentTaskNa !== void 0 ? _record$currentTaskNa : 0;
|
|
2634
|
+
const now = Date.now();
|
|
2635
|
+
const shouldRun = now > lastRun + currentTaskCoolDown;
|
|
2636
|
+
if (shouldRun) {
|
|
2637
|
+
taskResult = currentTask.invoke();
|
|
2638
|
+
next = merge(next, {
|
|
2639
|
+
record: merge(record, {
|
|
2640
|
+
[currentTaskName]: now
|
|
2641
|
+
})
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
await setBackstageManager(merge(manager, next));
|
|
2646
|
+
}
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
}
|
|
2649
|
+
return result;
|
|
2650
|
+
};
|
|
2405
2651
|
const ones = new Command("ones");
|
|
2406
|
-
const
|
|
2652
|
+
const packageJSON = getPackageJSON();
|
|
2653
|
+
const version = `${packageJSON.version}`;
|
|
2407
2654
|
const env = `${version} Node/${process.version}`;
|
|
2408
2655
|
ones.description(i18n.t("desc.ones", {
|
|
2409
2656
|
env
|
|
@@ -2420,9 +2667,12 @@ addCommandOutput(ones);
|
|
|
2420
2667
|
const runCommandONES = async () => {
|
|
2421
2668
|
const command = ones;
|
|
2422
2669
|
setContext("command", command);
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2425
|
-
await
|
|
2670
|
+
const {
|
|
2671
|
+
finish
|
|
2672
|
+
} = await invokeBackstage();
|
|
2673
|
+
command.version(version, "-v, --version");
|
|
2674
|
+
await command.parseAsync();
|
|
2675
|
+
await finish();
|
|
2426
2676
|
};
|
|
2427
2677
|
export {
|
|
2428
2678
|
runCommandONES
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAuB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmDvE,eAAO,MAAM,GAAG,GAAU,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAuB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmDvE,eAAO,MAAM,GAAG,GAAU,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,mBAyOrE,CAAA"}
|
|
@@ -4,7 +4,8 @@ export interface DevEnv extends ProcessEnv {
|
|
|
4
4
|
ONES_DEV_WEB_SERVER_PORT: string;
|
|
5
5
|
ONES_HOSTED_TOKEN: string;
|
|
6
6
|
ONES_HOSTED_APP_ID: string;
|
|
7
|
-
|
|
7
|
+
ONES_HOSTED_APP_BASE_URL: string;
|
|
8
|
+
ONES_HOSTED_MANAGER_BASE_URL: string;
|
|
8
9
|
}
|
|
9
10
|
export {};
|
|
10
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,OAAO,OAAO,CAAC,GAAG,CAAA;AAEpC,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,wBAAwB,EAAE,MAAM,CAAA;IAChC,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,OAAO,OAAO,CAAC,GAAG,CAAA;AAEpC,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,wBAAwB,EAAE,MAAM,CAAA;IAChC,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,wBAAwB,EAAE,MAAM,CAAA;IAChC,4BAA4B,EAAE,MAAM,CAAA;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/logout/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA0B,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAE7E,eAAO,MAAM,MAAM,GAAU,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/logout/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA0B,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAE7E,eAAO,MAAM,MAAM,GAAU,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,kBAc3E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,cAAc,qBAO1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/common/backstage/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;CAExB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/backstage/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface BackstageTaskItemInvokeResult {
|
|
2
|
+
finish(): Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
/** 由 backstage 后台执行器按 index 轮询执行的任务,具体业务由注册方实现 */
|
|
5
|
+
export interface BackstageTaskItem {
|
|
6
|
+
/** 任务唯一标识,用于 record 中存取上次运行时间戳 */
|
|
7
|
+
name: string;
|
|
8
|
+
/** 冷却时间(ms),上次运行时间 + cool_down 大于当前时间则不运行 */
|
|
9
|
+
cool_down: number;
|
|
10
|
+
invoke(): BackstageTaskItemInvokeResult;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/backstage/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,6BAA6B;IAC5C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB;AAED,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,IAAI,6BAA6B,CAAA;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/backstage/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,6BAA6B,EAAE,MAAM,SAAS,CAAA;AAI/E,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,6BAA6B,CA6C7E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/request/utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGvC,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAUhE,CAAA;AAED,eAAO,MAAM,0BAA0B,aAItC,CAAA;AAED,eAAO,MAAM,6BAA6B,aAGzC,CAAA;AAED,eAAO,MAAM,MAAM,GACjB,MAAM,MAAM,EACZ,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,WAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/request/utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGvC,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAUhE,CAAA;AAED,eAAO,MAAM,0BAA0B,aAItC,CAAA;AAED,eAAO,MAAM,6BAA6B,aAGzC,CAAA;AAED,eAAO,MAAM,MAAM,GACjB,MAAM,MAAM,EACZ,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,WAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,gCAalC,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjC,CAAA;AAED,eAAO,MAAM,+BAA+B,QAAa,OAAO,CAAC,MAAM,CAkDtE,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,UAAU,CAAC,OAAO,CAAC,OAiBrD,CAAA;AAED,eAAO,MAAM,YAAY,kBAcxB,CAAA"}
|
|
@@ -19,6 +19,28 @@ export declare const StoreONESTokenJSONSchema: z.ZodObject<{
|
|
|
19
19
|
refresh_token?: string | undefined;
|
|
20
20
|
}>;
|
|
21
21
|
export type StoreONESTokenJSON = z.infer<typeof StoreONESTokenJSONSchema>;
|
|
22
|
+
export declare const StoreVersionManagerJSONSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
23
|
+
latest_version: z.ZodOptional<z.ZodString>;
|
|
24
|
+
toast_count: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
latest_version?: string | undefined;
|
|
27
|
+
toast_count?: number | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
latest_version?: string | undefined;
|
|
30
|
+
toast_count?: number | undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
export type StoreVersionManagerJSON = z.infer<typeof StoreVersionManagerJSONSchema>;
|
|
33
|
+
export declare const StoreBackstageManagerJSONSchema: z.ZodObject<{
|
|
34
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
record: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
index?: number | undefined;
|
|
38
|
+
record?: Record<string, number> | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
index?: number | undefined;
|
|
41
|
+
record?: Record<string, number> | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
export type StoreBackstageManagerJSON = z.infer<typeof StoreBackstageManagerJSONSchema>;
|
|
22
44
|
export declare const StoreJSONSchema: z.ZodObject<{
|
|
23
45
|
version: z.ZodOptional<z.ZodString>;
|
|
24
46
|
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
@@ -44,6 +66,26 @@ export declare const StoreJSONSchema: z.ZodObject<{
|
|
|
44
66
|
access_token?: string | undefined;
|
|
45
67
|
refresh_token?: string | undefined;
|
|
46
68
|
}>>;
|
|
69
|
+
version_manager: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
70
|
+
latest_version: z.ZodOptional<z.ZodString>;
|
|
71
|
+
toast_count: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
latest_version?: string | undefined;
|
|
74
|
+
toast_count?: number | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
latest_version?: string | undefined;
|
|
77
|
+
toast_count?: number | undefined;
|
|
78
|
+
}>>>;
|
|
79
|
+
backstage_manager: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
record: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
index?: number | undefined;
|
|
84
|
+
record?: Record<string, number> | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
index?: number | undefined;
|
|
87
|
+
record?: Record<string, number> | undefined;
|
|
88
|
+
}>>;
|
|
47
89
|
}, "strip", z.ZodTypeAny, {
|
|
48
90
|
version?: string | undefined;
|
|
49
91
|
timestamp?: number | undefined;
|
|
@@ -57,6 +99,14 @@ export declare const StoreJSONSchema: z.ZodObject<{
|
|
|
57
99
|
access_token?: string | undefined;
|
|
58
100
|
refresh_token?: string | undefined;
|
|
59
101
|
} | undefined;
|
|
102
|
+
version_manager?: Record<string, {
|
|
103
|
+
latest_version?: string | undefined;
|
|
104
|
+
toast_count?: number | undefined;
|
|
105
|
+
}> | undefined;
|
|
106
|
+
backstage_manager?: {
|
|
107
|
+
index?: number | undefined;
|
|
108
|
+
record?: Record<string, number> | undefined;
|
|
109
|
+
} | undefined;
|
|
60
110
|
}, {
|
|
61
111
|
version?: string | undefined;
|
|
62
112
|
timestamp?: number | undefined;
|
|
@@ -70,6 +120,14 @@ export declare const StoreJSONSchema: z.ZodObject<{
|
|
|
70
120
|
access_token?: string | undefined;
|
|
71
121
|
refresh_token?: string | undefined;
|
|
72
122
|
} | undefined;
|
|
123
|
+
version_manager?: Record<string, {
|
|
124
|
+
latest_version?: string | undefined;
|
|
125
|
+
toast_count?: number | undefined;
|
|
126
|
+
}> | undefined;
|
|
127
|
+
backstage_manager?: {
|
|
128
|
+
index?: number | undefined;
|
|
129
|
+
record?: Record<string, number> | undefined;
|
|
130
|
+
} | undefined;
|
|
73
131
|
}>;
|
|
74
132
|
export type StoreJSON = z.infer<typeof StoreJSONSchema>;
|
|
75
133
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/common/store/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAMnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/common/store/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAMnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,eAAO,MAAM,6BAA6B;;;;;;;;;GAKzC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEnF,eAAO,MAAM,+BAA+B;;;;;;;;;EAG1C,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAEvF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StoreJSON, StoreONESTokenJSON } from './schema';
|
|
1
|
+
import type { StoreJSON, StoreONESTokenJSON, StoreVersionManagerJSON, StoreBackstageManagerJSON } from './schema';
|
|
2
2
|
export declare const getStore: () => Promise<StoreJSON>;
|
|
3
3
|
export declare const setStore: (store: StoreJSON) => Promise<void>;
|
|
4
4
|
export declare const mergeStore: (store: StoreJSON) => Promise<void>;
|
|
@@ -10,4 +10,8 @@ export declare const getONESToken: () => Promise<StoreONESTokenJSON>;
|
|
|
10
10
|
export declare const setONESToken: (token: StoreONESTokenJSON) => Promise<void>;
|
|
11
11
|
export declare const getHostToken: () => Promise<string>;
|
|
12
12
|
export declare const setHostToken: (token: string) => Promise<void>;
|
|
13
|
+
export declare const getVersionManager: () => Promise<StoreVersionManagerJSON>;
|
|
14
|
+
export declare const setVersionManager: (versionManager: StoreVersionManagerJSON) => Promise<void>;
|
|
15
|
+
export declare const getBackstageManager: () => Promise<StoreBackstageManagerJSON>;
|
|
16
|
+
export declare const setBackstageManager: (backstageManager: StoreBackstageManagerJSON) => Promise<void>;
|
|
13
17
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/store/utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/store/utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AASjB,eAAO,MAAM,QAAQ,QAAa,OAAO,CAAC,SAAS,CA2BlD,CAAA;AAED,eAAO,MAAM,QAAQ,GAAU,OAAO,SAAS,KAAG,OAAO,CAAC,IAAI,CA4B7D,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,OAAO,SAAS,KAAG,OAAO,CAAC,IAAI,CAM/D,CAAA;AAED,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,MAAM,CAGjD,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAE9D,CAAA;AAED,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,MAAM,CAGnD,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,WAAW,MAAM,KAAG,OAAO,CAAC,IAAI,CAElE,CAAA;AAED,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,kBAAkB,CAG/D,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,OAAO,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAE1E,CAAA;AAED,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,MAAM,CAGnD,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAE9D,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,uBAAuB,CAGzE,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAU,gBAAgB,uBAAuB,KAAG,OAAO,CAAC,IAAI,CAE7F,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,yBAAyB,CAG7E,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,kBAAkB,yBAAyB,KAC1C,OAAO,CAAC,IAAI,CAEd,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/common/version/consts.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAChC,SAAS,KAAK;IACd,KAAK,IAAI;IACT,YAAY,IAAI;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/version/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../../src/common/version/task.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAM3D,eAAO,MAAM,sBAAsB,EAAE,iBAgCpC,CAAA;AAID,eAAO,MAAM,sBAAsB,EAAE,iBAyCpC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VERSION_COMPARE_RESULT } from './consts';
|
|
2
|
+
export declare const fetchLatestVersion: (packageName: string) => {
|
|
3
|
+
promise: Promise<string>;
|
|
4
|
+
resolve: (value: string | PromiseLike<string>) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const compareVersion: (version1: string, version2: string) => VERSION_COMPARE_RESULT;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/version/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD,eAAO,MAAM,kBAAkB,GAAI,aAAa,MAAM;;;CA+BrD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,sBA8BnE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-open/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -60,12 +60,14 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@babel/runtime-corejs3": "~7.26.10",
|
|
63
|
+
"@clack/prompts": "^1.1.0",
|
|
63
64
|
"archiver": "^7.0.1",
|
|
64
65
|
"axios": "1.13.2",
|
|
66
|
+
"boxen": "7.1.0",
|
|
65
67
|
"chalk": "^5.0.1",
|
|
66
68
|
"commander": "~9.4.0",
|
|
67
69
|
"cosmiconfig": "^8.3.6",
|
|
68
|
-
"create-ones-app": "0.0.
|
|
70
|
+
"create-ones-app": "0.0.16",
|
|
69
71
|
"env-paths": "3.0.0",
|
|
70
72
|
"execa": "^6.1.0",
|
|
71
73
|
"fs-extra": "^11.3.0",
|
|
@@ -79,5 +81,5 @@
|
|
|
79
81
|
"ws": "^8.18.3",
|
|
80
82
|
"zod": "^3.22.2"
|
|
81
83
|
},
|
|
82
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "b2adde5a10ad78d262b2861a1f7efabd6d85c486"
|
|
83
85
|
}
|