@ones-open/cli 0.0.14 → 0.0.15

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 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",
@@ -1451,7 +1483,8 @@ const dev = async function() {
1451
1483
  ONES_DEV_WEB_SERVER_PORT: `${ONES_DEV_WEB_SERVER_PORT}`,
1452
1484
  ONES_HOSTED_TOKEN: "",
1453
1485
  ONES_HOSTED_APP_ID: "",
1454
- ONES_HOSTED_BASE_URL: ""
1486
+ ONES_HOSTED_APP_BASE_URL: "",
1487
+ ONES_HOSTED_MANAGER_BASE_URL: ""
1455
1488
  };
1456
1489
  const cancelWaiting = startWaiting();
1457
1490
  let enableTunnel = true;
@@ -1470,10 +1503,12 @@ const dev = async function() {
1470
1503
  const regionURL = await getRegionURL();
1471
1504
  const ONES_HOSTED_TOKEN = await getHostToken();
1472
1505
  const ONES_HOSTED_APP_ID = appID;
1473
- const ONES_HOSTED_BASE_URL = `${regionURL}/platform/runtime_manager`;
1506
+ const ONES_HOSTED_MANAGER_BASE_URL = `${regionURL}/platform/runtime_manager`;
1507
+ const ONES_HOSTED_APP_BASE_URL = await buildTunnelUrl();
1474
1508
  env2.ONES_HOSTED_TOKEN = ONES_HOSTED_TOKEN;
1475
1509
  env2.ONES_HOSTED_APP_ID = ONES_HOSTED_APP_ID;
1476
- env2.ONES_HOSTED_BASE_URL = ONES_HOSTED_BASE_URL;
1510
+ env2.ONES_HOSTED_APP_BASE_URL = ONES_HOSTED_APP_BASE_URL;
1511
+ env2.ONES_HOSTED_MANAGER_BASE_URL = ONES_HOSTED_MANAGER_BASE_URL;
1477
1512
  } else {
1478
1513
  console.log("Not logged in or token invalid, skipping tunnel connection...");
1479
1514
  }
@@ -1829,7 +1864,12 @@ const logout = async function() {
1829
1864
  } = createOnesApp.getCommandOptions(args, logoutCommandArguments);
1830
1865
  const normalizedOptions = await normalize$7(options);
1831
1866
  lodashEs.noop(normalizedOptions);
1832
- await setStore({});
1867
+ await mergeStore({
1868
+ base_url: "",
1869
+ region_url: "",
1870
+ host_token: "",
1871
+ ones_token: {}
1872
+ });
1833
1873
  console.log("Logged out successfully!");
1834
1874
  };
1835
1875
  const normalize$6 = async (options) => {
@@ -2405,8 +2445,210 @@ const $legacy = new commander.Command("legacy").description(i18n.t("desc.legacy"
2405
2445
  $legacy.addCommand($create);
2406
2446
  createOnesApp.addCommandUsage($legacy);
2407
2447
  createOnesApp.addCommandOutput($legacy);
2448
+ var VERSION_COMPARE_RESULT = /* @__PURE__ */ ((VERSION_COMPARE_RESULT2) => {
2449
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["LESS_THAN"] = -1] = "LESS_THAN";
2450
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["EQUAL"] = 0] = "EQUAL";
2451
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["GREATER_THAN"] = 1] = "GREATER_THAN";
2452
+ return VERSION_COMPARE_RESULT2;
2453
+ })(VERSION_COMPARE_RESULT || {});
2454
+ const fetchLatestVersion = (packageName2) => {
2455
+ const {
2456
+ promise,
2457
+ resolve
2458
+ } = createPromise();
2459
+ const child = node_child_process.spawn("npm", ["view", packageName2, "version"], {
2460
+ stdio: ["ignore", "pipe", "pipe"]
2461
+ });
2462
+ let stdout = "";
2463
+ child.stdout.on("data", (chunk) => {
2464
+ stdout += chunk.toString();
2465
+ });
2466
+ let running = true;
2467
+ child.on("close", (code) => {
2468
+ running = false;
2469
+ if (code !== 0) {
2470
+ resolve("");
2471
+ return;
2472
+ }
2473
+ resolve(stdout.trim());
2474
+ });
2475
+ child.on("error", () => {
2476
+ running = false;
2477
+ resolve("");
2478
+ });
2479
+ promise.then(() => {
2480
+ if (running) {
2481
+ child.kill();
2482
+ }
2483
+ });
2484
+ return {
2485
+ promise,
2486
+ resolve
2487
+ };
2488
+ };
2489
+ const compareVersion = (version1, version2) => {
2490
+ if (/[^0-9.]/.test(version1)) {
2491
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2492
+ }
2493
+ if (/[^0-9.]/.test(version2)) {
2494
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2495
+ }
2496
+ const [major1 = "0", minor1 = "0", patch1 = "0", rest1 = ""] = version1.split(".");
2497
+ const [major2 = "0", minor2 = "0", patch2 = "0", rest2 = ""] = version2.split(".");
2498
+ if (rest1 || rest2) {
2499
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2500
+ }
2501
+ const length1 = Math.max(major1.length, minor1.length, patch1.length);
2502
+ const length2 = Math.max(major2.length, minor2.length, patch2.length);
2503
+ const maxLength = Math.max(length1, length2);
2504
+ const major1String = major1.padStart(maxLength, "0");
2505
+ const major2String = major2.padStart(maxLength, "0");
2506
+ const minor1String = minor1.padStart(maxLength, "0");
2507
+ const minor2String = minor2.padStart(maxLength, "0");
2508
+ const patch1String = patch1.padStart(maxLength, "0");
2509
+ const patch2String = patch2.padStart(maxLength, "0");
2510
+ const version1String = `${major1String}${minor1String}${patch1String}`;
2511
+ const version2String = `${major2String}${minor2String}${patch2String}`;
2512
+ if (version1String === version2String) {
2513
+ return VERSION_COMPARE_RESULT.EQUAL;
2514
+ }
2515
+ if (version1String > version2String) {
2516
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2517
+ }
2518
+ return VERSION_COMPARE_RESULT.LESS_THAN;
2519
+ };
2520
+ const COOL_DOWN_MS = {
2521
+ ONE_DAY: 1e3 * 60 * 60 * 24
2522
+ };
2523
+ var _packageJSON$name, _packageJSON$version;
2524
+ const packageJSON$1 = getPackageJSON();
2525
+ const packageName = (_packageJSON$name = packageJSON$1.name) !== null && _packageJSON$name !== void 0 ? _packageJSON$name : "";
2526
+ const currentVersion = (_packageJSON$version = packageJSON$1.version) !== null && _packageJSON$version !== void 0 ? _packageJSON$version : "";
2527
+ const fetchLatestVersionTask = {
2528
+ name: "fetchLatestVersionTask",
2529
+ cool_down: COOL_DOWN_MS.ONE_DAY,
2530
+ invoke: () => {
2531
+ const {
2532
+ promise,
2533
+ resolve
2534
+ } = fetchLatestVersion(packageName);
2535
+ const throttle = sleep(1e3);
2536
+ return {
2537
+ finish: async () => {
2538
+ await throttle;
2539
+ resolve("");
2540
+ await promise.then(async (nextLatestVersion) => {
2541
+ if (nextLatestVersion) {
2542
+ if (nextLatestVersion !== currentVersion) {
2543
+ var _versionManager$packa, _record$latest_versio;
2544
+ const versionManager = await getVersionManager();
2545
+ const record = (_versionManager$packa = versionManager[packageName]) !== null && _versionManager$packa !== void 0 ? _versionManager$packa : {};
2546
+ const latestVersion = (_record$latest_versio = record.latest_version) !== null && _record$latest_versio !== void 0 ? _record$latest_versio : "";
2547
+ if (nextLatestVersion !== latestVersion) {
2548
+ await setVersionManager(lodashEs.merge(versionManager, {
2549
+ [packageName]: {
2550
+ latest_version: nextLatestVersion,
2551
+ toast_count: 0
2552
+ }
2553
+ }));
2554
+ }
2555
+ }
2556
+ }
2557
+ });
2558
+ }
2559
+ };
2560
+ }
2561
+ };
2562
+ const TOAST_COUNT_MAX = 3;
2563
+ const toastLatestVersionTask = {
2564
+ name: "toastLatestVersionTask",
2565
+ cool_down: COOL_DOWN_MS.ONE_DAY,
2566
+ invoke: () => {
2567
+ return {
2568
+ finish: async () => {
2569
+ const versionManager = await getVersionManager();
2570
+ const record = versionManager[packageName];
2571
+ if (record) {
2572
+ var _record$toast_count, _record$latest_versio2;
2573
+ const toastCount = (_record$toast_count = record.toast_count) !== null && _record$toast_count !== void 0 ? _record$toast_count : 0;
2574
+ const latestVersion = (_record$latest_versio2 = record.latest_version) !== null && _record$latest_versio2 !== void 0 ? _record$latest_versio2 : "";
2575
+ if (toastCount < TOAST_COUNT_MAX) {
2576
+ const compareResult = compareVersion(latestVersion, currentVersion);
2577
+ if (compareResult === VERSION_COMPARE_RESULT.GREATER_THAN) {
2578
+ const command = `npm install -g ${packageName}`;
2579
+ const message = [`A new version of ${chalk.yellow(packageName)} is available: ${chalk.yellow(latestVersion)}`, `Run ${chalk.yellow(command)} to update.`].join("\n");
2580
+ const result = boxen(message, {
2581
+ padding: 1,
2582
+ margin: 1,
2583
+ borderStyle: "round",
2584
+ borderColor: "yellow",
2585
+ title: `${packageName}`,
2586
+ titleAlignment: "center"
2587
+ });
2588
+ console.log(result);
2589
+ await setVersionManager(lodashEs.merge(versionManager, {
2590
+ [packageName]: {
2591
+ toast_count: toastCount + 1
2592
+ }
2593
+ }));
2594
+ }
2595
+ }
2596
+ }
2597
+ }
2598
+ };
2599
+ }
2600
+ };
2601
+ const taskItems = [fetchLatestVersionTask, toastLatestVersionTask];
2602
+ const invokeBackstage = async () => {
2603
+ let taskResult = null;
2604
+ const result = {
2605
+ finish: async () => {
2606
+ if (taskResult) {
2607
+ try {
2608
+ return await taskResult.finish();
2609
+ } catch (error) {
2610
+ }
2611
+ }
2612
+ return Promise.resolve();
2613
+ }
2614
+ };
2615
+ try {
2616
+ var _manager$index, _manager$record;
2617
+ const manager = await getBackstageManager();
2618
+ const index = (_manager$index = manager.index) !== null && _manager$index !== void 0 ? _manager$index : 0;
2619
+ const record = (_manager$record = manager.record) !== null && _manager$record !== void 0 ? _manager$record : {};
2620
+ if (taskItems.length > 0) {
2621
+ var _currentTask$name, _currentTask$cool_dow;
2622
+ let next = {
2623
+ index: index + 1
2624
+ };
2625
+ const currentTaskIndex = index % taskItems.length;
2626
+ const currentTask = taskItems[currentTaskIndex];
2627
+ const currentTaskName = (_currentTask$name = currentTask === null || currentTask === void 0 ? void 0 : currentTask.name) !== null && _currentTask$name !== void 0 ? _currentTask$name : "";
2628
+ 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;
2629
+ if (currentTaskName && currentTaskCoolDown) {
2630
+ var _record$currentTaskNa;
2631
+ const lastRun = (_record$currentTaskNa = record[currentTaskName]) !== null && _record$currentTaskNa !== void 0 ? _record$currentTaskNa : 0;
2632
+ const now = Date.now();
2633
+ const shouldRun = now > lastRun + currentTaskCoolDown;
2634
+ if (shouldRun) {
2635
+ taskResult = currentTask.invoke();
2636
+ next = lodashEs.merge(next, {
2637
+ record: lodashEs.merge(record, {
2638
+ [currentTaskName]: now
2639
+ })
2640
+ });
2641
+ }
2642
+ }
2643
+ await setBackstageManager(lodashEs.merge(manager, next));
2644
+ }
2645
+ } catch (error) {
2646
+ }
2647
+ return result;
2648
+ };
2408
2649
  const ones = new commander.Command("ones");
2409
- const version = `${getPackageJSON().version}`;
2650
+ const packageJSON = getPackageJSON();
2651
+ const version = `${packageJSON.version}`;
2410
2652
  const env = `${version} Node/${process.version}`;
2411
2653
  ones.description(i18n.t("desc.ones", {
2412
2654
  env
@@ -2423,8 +2665,11 @@ createOnesApp.addCommandOutput(ones);
2423
2665
  const runCommandONES = async () => {
2424
2666
  const command = ones;
2425
2667
  createOnesApp.setContext("command", command);
2426
- const version2 = `${getPackageJSON().version}`;
2427
- command.version(version2, "-v, --version");
2428
- await command.parse();
2668
+ const {
2669
+ finish
2670
+ } = await invokeBackstage();
2671
+ command.version(version, "-v, --version");
2672
+ await command.parseAsync();
2673
+ await finish();
2429
2674
  };
2430
2675
  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",
@@ -1448,7 +1480,8 @@ const dev = async function() {
1448
1480
  ONES_DEV_WEB_SERVER_PORT: `${ONES_DEV_WEB_SERVER_PORT}`,
1449
1481
  ONES_HOSTED_TOKEN: "",
1450
1482
  ONES_HOSTED_APP_ID: "",
1451
- ONES_HOSTED_BASE_URL: ""
1483
+ ONES_HOSTED_APP_BASE_URL: "",
1484
+ ONES_HOSTED_MANAGER_BASE_URL: ""
1452
1485
  };
1453
1486
  const cancelWaiting = startWaiting();
1454
1487
  let enableTunnel = true;
@@ -1467,10 +1500,12 @@ const dev = async function() {
1467
1500
  const regionURL = await getRegionURL();
1468
1501
  const ONES_HOSTED_TOKEN = await getHostToken();
1469
1502
  const ONES_HOSTED_APP_ID = appID;
1470
- const ONES_HOSTED_BASE_URL = `${regionURL}/platform/runtime_manager`;
1503
+ const ONES_HOSTED_MANAGER_BASE_URL = `${regionURL}/platform/runtime_manager`;
1504
+ const ONES_HOSTED_APP_BASE_URL = await buildTunnelUrl();
1471
1505
  env2.ONES_HOSTED_TOKEN = ONES_HOSTED_TOKEN;
1472
1506
  env2.ONES_HOSTED_APP_ID = ONES_HOSTED_APP_ID;
1473
- env2.ONES_HOSTED_BASE_URL = ONES_HOSTED_BASE_URL;
1507
+ env2.ONES_HOSTED_APP_BASE_URL = ONES_HOSTED_APP_BASE_URL;
1508
+ env2.ONES_HOSTED_MANAGER_BASE_URL = ONES_HOSTED_MANAGER_BASE_URL;
1474
1509
  } else {
1475
1510
  console.log("Not logged in or token invalid, skipping tunnel connection...");
1476
1511
  }
@@ -1826,7 +1861,12 @@ const logout = async function() {
1826
1861
  } = getCommandOptions(args, logoutCommandArguments);
1827
1862
  const normalizedOptions = await normalize$7(options);
1828
1863
  noop(normalizedOptions);
1829
- await setStore({});
1864
+ await mergeStore({
1865
+ base_url: "",
1866
+ region_url: "",
1867
+ host_token: "",
1868
+ ones_token: {}
1869
+ });
1830
1870
  console.log("Logged out successfully!");
1831
1871
  };
1832
1872
  const normalize$6 = async (options) => {
@@ -2402,8 +2442,210 @@ const $legacy = new Command("legacy").description(i18n.t("desc.legacy"));
2402
2442
  $legacy.addCommand($create);
2403
2443
  addCommandUsage($legacy);
2404
2444
  addCommandOutput($legacy);
2445
+ var VERSION_COMPARE_RESULT = /* @__PURE__ */ ((VERSION_COMPARE_RESULT2) => {
2446
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["LESS_THAN"] = -1] = "LESS_THAN";
2447
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["EQUAL"] = 0] = "EQUAL";
2448
+ VERSION_COMPARE_RESULT2[VERSION_COMPARE_RESULT2["GREATER_THAN"] = 1] = "GREATER_THAN";
2449
+ return VERSION_COMPARE_RESULT2;
2450
+ })(VERSION_COMPARE_RESULT || {});
2451
+ const fetchLatestVersion = (packageName2) => {
2452
+ const {
2453
+ promise,
2454
+ resolve: resolve2
2455
+ } = createPromise();
2456
+ const child = spawn("npm", ["view", packageName2, "version"], {
2457
+ stdio: ["ignore", "pipe", "pipe"]
2458
+ });
2459
+ let stdout = "";
2460
+ child.stdout.on("data", (chunk) => {
2461
+ stdout += chunk.toString();
2462
+ });
2463
+ let running = true;
2464
+ child.on("close", (code) => {
2465
+ running = false;
2466
+ if (code !== 0) {
2467
+ resolve2("");
2468
+ return;
2469
+ }
2470
+ resolve2(stdout.trim());
2471
+ });
2472
+ child.on("error", () => {
2473
+ running = false;
2474
+ resolve2("");
2475
+ });
2476
+ promise.then(() => {
2477
+ if (running) {
2478
+ child.kill();
2479
+ }
2480
+ });
2481
+ return {
2482
+ promise,
2483
+ resolve: resolve2
2484
+ };
2485
+ };
2486
+ const compareVersion = (version1, version2) => {
2487
+ if (/[^0-9.]/.test(version1)) {
2488
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2489
+ }
2490
+ if (/[^0-9.]/.test(version2)) {
2491
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2492
+ }
2493
+ const [major1 = "0", minor1 = "0", patch1 = "0", rest1 = ""] = version1.split(".");
2494
+ const [major2 = "0", minor2 = "0", patch2 = "0", rest2 = ""] = version2.split(".");
2495
+ if (rest1 || rest2) {
2496
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2497
+ }
2498
+ const length1 = Math.max(major1.length, minor1.length, patch1.length);
2499
+ const length2 = Math.max(major2.length, minor2.length, patch2.length);
2500
+ const maxLength = Math.max(length1, length2);
2501
+ const major1String = major1.padStart(maxLength, "0");
2502
+ const major2String = major2.padStart(maxLength, "0");
2503
+ const minor1String = minor1.padStart(maxLength, "0");
2504
+ const minor2String = minor2.padStart(maxLength, "0");
2505
+ const patch1String = patch1.padStart(maxLength, "0");
2506
+ const patch2String = patch2.padStart(maxLength, "0");
2507
+ const version1String = `${major1String}${minor1String}${patch1String}`;
2508
+ const version2String = `${major2String}${minor2String}${patch2String}`;
2509
+ if (version1String === version2String) {
2510
+ return VERSION_COMPARE_RESULT.EQUAL;
2511
+ }
2512
+ if (version1String > version2String) {
2513
+ return VERSION_COMPARE_RESULT.GREATER_THAN;
2514
+ }
2515
+ return VERSION_COMPARE_RESULT.LESS_THAN;
2516
+ };
2517
+ const COOL_DOWN_MS = {
2518
+ ONE_DAY: 1e3 * 60 * 60 * 24
2519
+ };
2520
+ var _packageJSON$name, _packageJSON$version;
2521
+ const packageJSON$1 = getPackageJSON();
2522
+ const packageName = (_packageJSON$name = packageJSON$1.name) !== null && _packageJSON$name !== void 0 ? _packageJSON$name : "";
2523
+ const currentVersion = (_packageJSON$version = packageJSON$1.version) !== null && _packageJSON$version !== void 0 ? _packageJSON$version : "";
2524
+ const fetchLatestVersionTask = {
2525
+ name: "fetchLatestVersionTask",
2526
+ cool_down: COOL_DOWN_MS.ONE_DAY,
2527
+ invoke: () => {
2528
+ const {
2529
+ promise,
2530
+ resolve: resolve2
2531
+ } = fetchLatestVersion(packageName);
2532
+ const throttle = sleep(1e3);
2533
+ return {
2534
+ finish: async () => {
2535
+ await throttle;
2536
+ resolve2("");
2537
+ await promise.then(async (nextLatestVersion) => {
2538
+ if (nextLatestVersion) {
2539
+ if (nextLatestVersion !== currentVersion) {
2540
+ var _versionManager$packa, _record$latest_versio;
2541
+ const versionManager = await getVersionManager();
2542
+ const record = (_versionManager$packa = versionManager[packageName]) !== null && _versionManager$packa !== void 0 ? _versionManager$packa : {};
2543
+ const latestVersion = (_record$latest_versio = record.latest_version) !== null && _record$latest_versio !== void 0 ? _record$latest_versio : "";
2544
+ if (nextLatestVersion !== latestVersion) {
2545
+ await setVersionManager(merge(versionManager, {
2546
+ [packageName]: {
2547
+ latest_version: nextLatestVersion,
2548
+ toast_count: 0
2549
+ }
2550
+ }));
2551
+ }
2552
+ }
2553
+ }
2554
+ });
2555
+ }
2556
+ };
2557
+ }
2558
+ };
2559
+ const TOAST_COUNT_MAX = 3;
2560
+ const toastLatestVersionTask = {
2561
+ name: "toastLatestVersionTask",
2562
+ cool_down: COOL_DOWN_MS.ONE_DAY,
2563
+ invoke: () => {
2564
+ return {
2565
+ finish: async () => {
2566
+ const versionManager = await getVersionManager();
2567
+ const record = versionManager[packageName];
2568
+ if (record) {
2569
+ var _record$toast_count, _record$latest_versio2;
2570
+ const toastCount = (_record$toast_count = record.toast_count) !== null && _record$toast_count !== void 0 ? _record$toast_count : 0;
2571
+ const latestVersion = (_record$latest_versio2 = record.latest_version) !== null && _record$latest_versio2 !== void 0 ? _record$latest_versio2 : "";
2572
+ if (toastCount < TOAST_COUNT_MAX) {
2573
+ const compareResult = compareVersion(latestVersion, currentVersion);
2574
+ if (compareResult === VERSION_COMPARE_RESULT.GREATER_THAN) {
2575
+ const command = `npm install -g ${packageName}`;
2576
+ const message = [`A new version of ${chalk.yellow(packageName)} is available: ${chalk.yellow(latestVersion)}`, `Run ${chalk.yellow(command)} to update.`].join("\n");
2577
+ const result = boxen(message, {
2578
+ padding: 1,
2579
+ margin: 1,
2580
+ borderStyle: "round",
2581
+ borderColor: "yellow",
2582
+ title: `${packageName}`,
2583
+ titleAlignment: "center"
2584
+ });
2585
+ console.log(result);
2586
+ await setVersionManager(merge(versionManager, {
2587
+ [packageName]: {
2588
+ toast_count: toastCount + 1
2589
+ }
2590
+ }));
2591
+ }
2592
+ }
2593
+ }
2594
+ }
2595
+ };
2596
+ }
2597
+ };
2598
+ const taskItems = [fetchLatestVersionTask, toastLatestVersionTask];
2599
+ const invokeBackstage = async () => {
2600
+ let taskResult = null;
2601
+ const result = {
2602
+ finish: async () => {
2603
+ if (taskResult) {
2604
+ try {
2605
+ return await taskResult.finish();
2606
+ } catch (error) {
2607
+ }
2608
+ }
2609
+ return Promise.resolve();
2610
+ }
2611
+ };
2612
+ try {
2613
+ var _manager$index, _manager$record;
2614
+ const manager = await getBackstageManager();
2615
+ const index = (_manager$index = manager.index) !== null && _manager$index !== void 0 ? _manager$index : 0;
2616
+ const record = (_manager$record = manager.record) !== null && _manager$record !== void 0 ? _manager$record : {};
2617
+ if (taskItems.length > 0) {
2618
+ var _currentTask$name, _currentTask$cool_dow;
2619
+ let next = {
2620
+ index: index + 1
2621
+ };
2622
+ const currentTaskIndex = index % taskItems.length;
2623
+ const currentTask = taskItems[currentTaskIndex];
2624
+ const currentTaskName = (_currentTask$name = currentTask === null || currentTask === void 0 ? void 0 : currentTask.name) !== null && _currentTask$name !== void 0 ? _currentTask$name : "";
2625
+ 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;
2626
+ if (currentTaskName && currentTaskCoolDown) {
2627
+ var _record$currentTaskNa;
2628
+ const lastRun = (_record$currentTaskNa = record[currentTaskName]) !== null && _record$currentTaskNa !== void 0 ? _record$currentTaskNa : 0;
2629
+ const now = Date.now();
2630
+ const shouldRun = now > lastRun + currentTaskCoolDown;
2631
+ if (shouldRun) {
2632
+ taskResult = currentTask.invoke();
2633
+ next = merge(next, {
2634
+ record: merge(record, {
2635
+ [currentTaskName]: now
2636
+ })
2637
+ });
2638
+ }
2639
+ }
2640
+ await setBackstageManager(merge(manager, next));
2641
+ }
2642
+ } catch (error) {
2643
+ }
2644
+ return result;
2645
+ };
2405
2646
  const ones = new Command("ones");
2406
- const version = `${getPackageJSON().version}`;
2647
+ const packageJSON = getPackageJSON();
2648
+ const version = `${packageJSON.version}`;
2407
2649
  const env = `${version} Node/${process.version}`;
2408
2650
  ones.description(i18n.t("desc.ones", {
2409
2651
  env
@@ -2420,9 +2662,12 @@ addCommandOutput(ones);
2420
2662
  const runCommandONES = async () => {
2421
2663
  const command = ones;
2422
2664
  setContext("command", command);
2423
- const version2 = `${getPackageJSON().version}`;
2424
- command.version(version2, "-v, --version");
2425
- await command.parse();
2665
+ const {
2666
+ finish
2667
+ } = await invokeBackstage();
2668
+ command.version(version, "-v, --version");
2669
+ await command.parseAsync();
2670
+ await finish();
2426
2671
  };
2427
2672
  export {
2428
2673
  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,mBAsOrE,CAAA"}
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
- ONES_HOSTED_BASE_URL: string;
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,oBAAoB,EAAE,MAAM,CAAA;CAC7B"}
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,kBAS3E,CAAA"}
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":"AAuCA,eAAO,MAAM,cAAc,qBAM1B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,cAAc,qBAO1B,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const COOL_DOWN_MS: {
2
+ ONE_DAY: number;
3
+ };
4
+ //# sourceMappingURL=consts.d.ts.map
@@ -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,7 @@
1
+ /**
2
+ * 处理后台任务的工具
3
+ */
4
+ export * from './utils';
5
+ export * from './types';
6
+ export * from './consts';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ import type { BackstageTaskItemInvokeResult } from './types';
2
+ export declare const invokeBackstage: () => Promise<BackstageTaskItemInvokeResult>;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -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"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
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,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAS7D,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"}
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,6 @@
1
+ export declare enum VERSION_COMPARE_RESULT {
2
+ LESS_THAN = -1,
3
+ EQUAL = 0,
4
+ GREATER_THAN = 1
5
+ }
6
+ //# sourceMappingURL=consts.d.ts.map
@@ -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,6 @@
1
+ /**
2
+ * 处理版本信息的工具
3
+ */
4
+ export * from './utils';
5
+ export * from './task';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -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,4 @@
1
+ import type { BackstageTaskItem } from '../../common/backstage';
2
+ export declare const fetchLatestVersionTask: BackstageTaskItem;
3
+ export declare const toastLatestVersionTask: BackstageTaskItem;
4
+ //# sourceMappingURL=task.d.ts.map
@@ -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.14",
3
+ "version": "0.0.15",
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.14",
70
+ "create-ones-app": "0.0.15",
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": "bd884b7645c4304fbaac9fbcc8685e7e79fdb966"
84
+ "gitHead": "f4ef0edb32bd6daca6f0175c726342b1d7c527d6"
83
85
  }