@take-out/cli 0.4.3 → 0.4.5

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.
Files changed (69) hide show
  1. package/dist/cjs/cli.cjs +53 -35
  2. package/dist/cjs/commands/changed.cjs +133 -95
  3. package/dist/cjs/commands/docs.cjs +276 -203
  4. package/dist/cjs/commands/env-setup.cjs +45 -33
  5. package/dist/cjs/commands/onboard.cjs +668 -224
  6. package/dist/cjs/commands/run-all.cjs +54 -45
  7. package/dist/cjs/commands/run.cjs +80 -65
  8. package/dist/cjs/commands/script.cjs +263 -187
  9. package/dist/cjs/commands/skills.cjs +174 -118
  10. package/dist/cjs/commands/sync.cjs +193 -93
  11. package/dist/cjs/constants/ascii.cjs +14 -12
  12. package/dist/cjs/index.cjs +12 -10
  13. package/dist/cjs/types.cjs +7 -5
  14. package/dist/cjs/utils/env-categories.cjs +53 -48
  15. package/dist/cjs/utils/env-setup.cjs +214 -106
  16. package/dist/cjs/utils/env.cjs +65 -44
  17. package/dist/cjs/utils/files.cjs +186 -113
  18. package/dist/cjs/utils/parallel-runner.cjs +125 -75
  19. package/dist/cjs/utils/ports.cjs +21 -21
  20. package/dist/cjs/utils/prerequisites.cjs +42 -34
  21. package/dist/cjs/utils/prompts.cjs +66 -41
  22. package/dist/cjs/utils/script-listing.cjs +130 -60
  23. package/dist/cjs/utils/script-utils.cjs +29 -19
  24. package/dist/cjs/utils/sync.cjs +67 -45
  25. package/dist/esm/cli.mjs +40 -24
  26. package/dist/esm/cli.mjs.map +1 -1
  27. package/dist/esm/commands/changed.mjs +104 -68
  28. package/dist/esm/commands/changed.mjs.map +1 -1
  29. package/dist/esm/commands/docs.mjs +245 -174
  30. package/dist/esm/commands/docs.mjs.map +1 -1
  31. package/dist/esm/commands/env-setup.mjs +18 -8
  32. package/dist/esm/commands/env-setup.mjs.map +1 -1
  33. package/dist/esm/commands/onboard.mjs +631 -189
  34. package/dist/esm/commands/onboard.mjs.map +1 -1
  35. package/dist/esm/commands/run-all.mjs +26 -19
  36. package/dist/esm/commands/run-all.mjs.map +1 -1
  37. package/dist/esm/commands/run.mjs +52 -39
  38. package/dist/esm/commands/run.mjs.map +1 -1
  39. package/dist/esm/commands/script.mjs +230 -156
  40. package/dist/esm/commands/script.mjs.map +1 -1
  41. package/dist/esm/commands/skills.mjs +143 -89
  42. package/dist/esm/commands/skills.mjs.map +1 -1
  43. package/dist/esm/commands/sync.mjs +160 -62
  44. package/dist/esm/commands/sync.mjs.map +1 -1
  45. package/dist/esm/constants/ascii.mjs +2 -2
  46. package/dist/esm/constants/ascii.mjs.map +1 -1
  47. package/dist/esm/utils/env-categories.mjs +29 -26
  48. package/dist/esm/utils/env-categories.mjs.map +1 -1
  49. package/dist/esm/utils/env-setup.mjs +184 -78
  50. package/dist/esm/utils/env-setup.mjs.map +1 -1
  51. package/dist/esm/utils/env.mjs +50 -31
  52. package/dist/esm/utils/env.mjs.map +1 -1
  53. package/dist/esm/utils/files.mjs +171 -100
  54. package/dist/esm/utils/files.mjs.map +1 -1
  55. package/dist/esm/utils/parallel-runner.mjs +111 -63
  56. package/dist/esm/utils/parallel-runner.mjs.map +1 -1
  57. package/dist/esm/utils/ports.mjs +9 -11
  58. package/dist/esm/utils/ports.mjs.map +1 -1
  59. package/dist/esm/utils/prerequisites.mjs +30 -24
  60. package/dist/esm/utils/prerequisites.mjs.map +1 -1
  61. package/dist/esm/utils/prompts.mjs +40 -17
  62. package/dist/esm/utils/prompts.mjs.map +1 -1
  63. package/dist/esm/utils/script-listing.mjs +101 -33
  64. package/dist/esm/utils/script-listing.mjs.map +1 -1
  65. package/dist/esm/utils/script-utils.mjs +14 -6
  66. package/dist/esm/utils/script-utils.mjs.map +1 -1
  67. package/dist/esm/utils/sync.mjs +38 -18
  68. package/dist/esm/utils/sync.mjs.map +1 -1
  69. package/package.json +5 -5
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var script_utils_exports = {};
22
24
  __export(script_utils_exports, {
@@ -25,9 +27,9 @@ __export(script_utils_exports, {
25
27
  getLocalScriptsDir: () => getLocalScriptsDir
26
28
  });
27
29
  module.exports = __toCommonJS(script_utils_exports);
28
- var import_node_fs = require("node:fs"),
29
- import_node_path = require("node:path"),
30
- import_cmd = require("@take-out/scripts/cmd");
30
+ var import_node_fs = require("node:fs");
31
+ var import_node_path = require("node:path");
32
+ var import_cmd = require("@take-out/scripts/cmd");
31
33
  function getLocalScriptsDir() {
32
34
  return (0, import_node_path.join)(process.cwd(), "scripts");
33
35
  }
@@ -39,7 +41,8 @@ async function getAllScriptMetadata(scripts) {
39
41
  });
40
42
  for (const [name, path] of scripts) {
41
43
  try {
42
- if (!(0, import_node_fs.readFileSync)(path, "utf-8").slice(0, 200).includes("cmd")) continue;
44
+ const head = (0, import_node_fs.readFileSync)(path, "utf-8").slice(0, 200);
45
+ if (!head.includes("cmd")) continue;
43
46
  } catch {
44
47
  continue;
45
48
  }
@@ -55,7 +58,9 @@ async function getAllScriptMetadata(scripts) {
55
58
  };
56
59
  if (info.args) {
57
60
  const flags = [...info.args.matchAll(/--?([a-z-]+)/gi)];
58
- flags.length > 0 && (metadata.args = flags.map(m => `--${m[1]}`));
61
+ if (flags.length > 0) {
62
+ metadata.args = flags.map(m => `--${m[1]}`);
63
+ }
59
64
  }
60
65
  results.set(name, metadata);
61
66
  }
@@ -63,23 +68,28 @@ async function getAllScriptMetadata(scripts) {
63
68
  }
64
69
  function discoverScripts(dir, baseDir = dir) {
65
70
  const scripts = /* @__PURE__ */new Map();
66
- if (!(0, import_node_fs.existsSync)(dir)) return scripts;
71
+ if (!(0, import_node_fs.existsSync)(dir)) {
72
+ return scripts;
73
+ }
67
74
  try {
68
75
  const entries = (0, import_node_fs.readdirSync)(dir);
69
76
  for (const entry of entries) {
70
77
  const fullPath = (0, import_node_path.join)(dir, entry);
71
- if ((0, import_node_fs.statSync)(fullPath).isDirectory()) {
78
+ const stat = (0, import_node_fs.statSync)(fullPath);
79
+ if (stat.isDirectory()) {
72
80
  if (entry === "helpers" || entry === "internal") continue;
73
81
  const subEntries = (0, import_node_fs.readdirSync)(fullPath);
74
82
  for (const subEntry of subEntries) {
75
83
  const subPath = (0, import_node_path.join)(fullPath, subEntry);
76
84
  if ((0, import_node_fs.statSync)(subPath).isFile() && (subEntry.endsWith(".ts") || subEntry.endsWith(".js"))) {
77
- const scriptName = (0, import_node_path.relative)(baseDir, subPath).split("\\").join("/").replace(/\.(ts|js)$/, "");
85
+ const relativePath = (0, import_node_path.relative)(baseDir, subPath).split("\\").join("/");
86
+ const scriptName = relativePath.replace(/\.(ts|js)$/, "");
78
87
  scripts.set(scriptName, subPath);
79
88
  }
80
89
  }
81
90
  } else if (entry.endsWith(".ts") || entry.endsWith(".js")) {
82
- const scriptName = (0, import_node_path.relative)(baseDir, fullPath).split("\\").join("/").replace(/\.(ts|js)$/, "");
91
+ const relativePath = (0, import_node_path.relative)(baseDir, fullPath).split("\\").join("/");
92
+ const scriptName = relativePath.replace(/\.(ts|js)$/, "");
83
93
  scripts.set(scriptName, fullPath);
84
94
  }
85
95
  }
@@ -2,33 +2,35 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var sync_exports = {};
33
35
  __export(sync_exports, {
34
36
  compareFiles: () => compareFiles,
@@ -37,44 +39,64 @@ __export(sync_exports, {
37
39
  syncFileWithConfirmation: () => syncFileWithConfirmation
38
40
  });
39
41
  module.exports = __toCommonJS(sync_exports);
40
- var import_node_crypto = require("node:crypto"),
41
- import_node_fs = require("node:fs"),
42
- import_node_path = require("node:path"),
43
- import_prompts = require("@clack/prompts"),
44
- import_picocolors = __toESM(require("picocolors"), 1);
42
+ var import_node_crypto = require("node:crypto");
43
+ var import_node_fs = require("node:fs");
44
+ var import_node_path = require("node:path");
45
+ var import_prompts = require("@clack/prompts");
46
+ var import_picocolors = __toESM(require("picocolors"), 1);
45
47
  function getFileHash(filePath) {
46
48
  const content = (0, import_node_fs.readFileSync)(filePath);
47
49
  return (0, import_node_crypto.createHash)("md5").update(content).digest("hex");
48
50
  }
49
51
  function compareFiles(sourcePath, targetPath) {
50
- if (!(0, import_node_fs.existsSync)(targetPath)) return "new";
51
- const sourceHash = getFileHash(sourcePath),
52
- targetHash = getFileHash(targetPath);
52
+ if (!(0, import_node_fs.existsSync)(targetPath)) {
53
+ return "new";
54
+ }
55
+ const sourceHash = getFileHash(sourcePath);
56
+ const targetHash = getFileHash(targetPath);
53
57
  return sourceHash === targetHash ? "identical" : "modified";
54
58
  }
55
59
  async function syncFileWithConfirmation(file) {
56
60
  const relPath = (0, import_node_path.relative)(process.cwd(), file.targetPath);
57
- if (file.status === "identical") return console.info(import_picocolors.default.dim(` \u2713 ${file.name} (already up to date)`)), !1;
58
- const statusColor = file.status === "new" ? import_picocolors.default.green : import_picocolors.default.yellow,
59
- statusText = file.status === "new" ? "NEW" : "MODIFIED";
60
- if (console.info(), console.info(statusColor(` ${statusText}: ${file.name}`)), file.status === "modified") {
61
- const sourceSize = file.sourceSize || 0,
62
- targetSize = file.targetSize || 0,
63
- diff = sourceSize - targetSize;
64
- console.info(import_picocolors.default.dim(` Source: ${sourceSize} bytes`)), console.info(import_picocolors.default.dim(` Target: ${targetSize} bytes`)), diff > 0 ? console.info(import_picocolors.default.cyan(` Source is ${diff} bytes larger`)) : diff < 0 && console.info(import_picocolors.default.magenta(` Target is ${Math.abs(diff)} bytes larger`));
61
+ if (file.status === "identical") {
62
+ console.info(import_picocolors.default.dim(` \u2713 ${file.name} (already up to date)`));
63
+ return false;
64
+ }
65
+ const statusColor = file.status === "new" ? import_picocolors.default.green : import_picocolors.default.yellow;
66
+ const statusText = file.status === "new" ? "NEW" : "MODIFIED";
67
+ console.info();
68
+ console.info(statusColor(` ${statusText}: ${file.name}`));
69
+ if (file.status === "modified") {
70
+ const sourceSize = file.sourceSize || 0;
71
+ const targetSize = file.targetSize || 0;
72
+ const diff = sourceSize - targetSize;
73
+ console.info(import_picocolors.default.dim(` Source: ${sourceSize} bytes`));
74
+ console.info(import_picocolors.default.dim(` Target: ${targetSize} bytes`));
75
+ if (diff > 0) {
76
+ console.info(import_picocolors.default.cyan(` Source is ${diff} bytes larger`));
77
+ } else if (diff < 0) {
78
+ console.info(import_picocolors.default.magenta(` Target is ${Math.abs(diff)} bytes larger`));
79
+ }
65
80
  }
66
81
  console.info(import_picocolors.default.dim(` \u2192 ${relPath}`));
67
82
  const shouldSync = await (0, import_prompts.confirm)({
68
- message: "Overwrite this file?",
69
- initialValue: !0
83
+ message: `Overwrite this file?`,
84
+ initialValue: true
70
85
  });
71
- if (shouldSync === !1 || typeof shouldSync == "symbol") return console.info(import_picocolors.default.dim(" \u2298 Skipped")), !1;
86
+ if (shouldSync === false || typeof shouldSync === "symbol") {
87
+ console.info(import_picocolors.default.dim(` \u2298 Skipped`));
88
+ return false;
89
+ }
72
90
  const targetDir = (0, import_node_path.dirname)(file.targetPath);
73
- (0, import_node_fs.existsSync)(targetDir) || (0, import_node_fs.mkdirSync)(targetDir, {
74
- recursive: !0
75
- });
91
+ if (!(0, import_node_fs.existsSync)(targetDir)) {
92
+ (0, import_node_fs.mkdirSync)(targetDir, {
93
+ recursive: true
94
+ });
95
+ }
76
96
  const content = (0, import_node_fs.readFileSync)(file.sourcePath);
77
- return (0, import_node_fs.writeFileSync)(file.targetPath, content), console.info(import_picocolors.default.green(" \u2713 Synced")), !0;
97
+ (0, import_node_fs.writeFileSync)(file.targetPath, content);
98
+ console.info(import_picocolors.default.green(` \u2713 Synced`));
99
+ return true;
78
100
  }
79
101
  function getFileSize(filePath) {
80
102
  try {
package/dist/esm/cli.mjs CHANGED
@@ -4,20 +4,22 @@ import { existsSync, statSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { defineCommand, runMain } from "citty";
6
6
  function isScriptCategory(name) {
7
- const scriptsDir = join(process.cwd(), "scripts"),
8
- categoryPath = join(scriptsDir, name);
7
+ const scriptsDir = join(process.cwd(), "scripts");
8
+ const categoryPath = join(scriptsDir, name);
9
9
  try {
10
10
  return existsSync(categoryPath) && statSync(categoryPath).isDirectory();
11
11
  } catch {
12
- return !1;
12
+ return false;
13
13
  }
14
14
  }
15
15
  function findLocalScript(name) {
16
- const scriptsDir = join(process.cwd(), "scripts"),
17
- normalizedName = name.replace(/:/g, "/");
16
+ const scriptsDir = join(process.cwd(), "scripts");
17
+ const normalizedName = name.replace(/:/g, "/");
18
18
  for (const ext of [".ts", ".js", ""]) {
19
19
  const scriptPath = join(scriptsDir, `${normalizedName}${ext}`);
20
- if (existsSync(scriptPath)) return scriptPath;
20
+ if (existsSync(scriptPath)) {
21
+ return scriptPath;
22
+ }
21
23
  }
22
24
  return null;
23
25
  }
@@ -26,14 +28,16 @@ function isLocalScript(name) {
26
28
  }
27
29
  function findBuiltInScript(name) {
28
30
  try {
29
- const resolved = import.meta.resolve("@take-out/scripts/package.json"),
30
- packageJsonPath = new URL(resolved).pathname,
31
- packageRoot = join(packageJsonPath, ".."),
32
- srcPath = join(packageRoot, "src"),
33
- normalizedName = name.replace(/:/g, "/");
31
+ const resolved = import.meta.resolve("@take-out/scripts/package.json");
32
+ const packageJsonPath = new URL(resolved).pathname;
33
+ const packageRoot = join(packageJsonPath, "..");
34
+ const srcPath = join(packageRoot, "src");
35
+ const normalizedName = name.replace(/:/g, "/");
34
36
  for (const ext of [".ts", ".js", ""]) {
35
37
  const scriptPath = join(srcPath, `${normalizedName}${ext}`);
36
- if (existsSync(scriptPath)) return scriptPath;
38
+ if (existsSync(scriptPath)) {
39
+ return scriptPath;
40
+ }
37
41
  }
38
42
  } catch {}
39
43
  return null;
@@ -41,29 +45,40 @@ function findBuiltInScript(name) {
41
45
  function isBuiltInScript(name) {
42
46
  return findBuiltInScript(name) !== null;
43
47
  }
44
- const isShorthand = !0;
48
+ const isShorthand = true;
45
49
  if (isShorthand) {
46
50
  const firstArg = process.argv[2];
47
- if (firstArg && !["docs", "onboard", "run", "run-all", "script", "skills", "env:setup", "sync", "changed", "--help", "-h", "--version", "-v"].includes(firstArg)) {
51
+ const builtInCommands = ["docs", "onboard", "run", "run-all", "script", "skills", "env:setup", "sync", "changed", "--help", "-h", "--version", "-v"];
52
+ if (firstArg && !builtInCommands.includes(firstArg)) {
48
53
  let resolvedScriptName;
49
54
  if (isScriptCategory(firstArg)) {
50
- const restArgs = process.argv.slice(3),
51
- subScriptIdx = restArgs.findIndex(a => !a.startsWith("-"));
55
+ const restArgs = process.argv.slice(3);
56
+ const subScriptIdx = restArgs.findIndex(a => !a.startsWith("-"));
52
57
  if (subScriptIdx !== -1) {
53
58
  const subScript = restArgs[subScriptIdx];
54
- resolvedScriptName = `${firstArg}/${subScript}`, process.argv.splice(3 + subScriptIdx, 1), process.argv[2] = resolvedScriptName;
59
+ resolvedScriptName = `${firstArg}/${subScript}`;
60
+ process.argv.splice(3 + subScriptIdx, 1);
61
+ process.argv[2] = resolvedScriptName;
55
62
  }
56
63
  process.argv.splice(2, 0, "run");
57
- } else firstArg?.includes("/") || isLocalScript(firstArg) || isBuiltInScript(firstArg) ? (resolvedScriptName = firstArg, process.argv.splice(2, 0, "run")) : process.argv.splice(2, 0, "script");
64
+ } else if (firstArg?.includes("/")) {
65
+ resolvedScriptName = firstArg;
66
+ process.argv.splice(2, 0, "run");
67
+ } else if (isLocalScript(firstArg) || isBuiltInScript(firstArg)) {
68
+ resolvedScriptName = firstArg;
69
+ process.argv.splice(2, 0, "run");
70
+ } else {
71
+ process.argv.splice(2, 0, "script");
72
+ }
58
73
  const hasHelp = process.argv.includes("--help") || process.argv.includes("-h");
59
74
  if (resolvedScriptName && hasHelp) {
60
75
  const scriptPath = findLocalScript(resolvedScriptName) || findBuiltInScript(resolvedScriptName);
61
76
  if (scriptPath) {
62
- const flagArgs = process.argv.slice(3).filter(a => a !== resolvedScriptName),
63
- result = spawnSync("bun", [scriptPath, ...flagArgs], {
64
- stdio: "inherit",
65
- shell: !1
66
- });
77
+ const flagArgs = process.argv.slice(3).filter(a => a !== resolvedScriptName);
78
+ const result = spawnSync("bun", [scriptPath, ...flagArgs], {
79
+ stdio: "inherit",
80
+ shell: false
81
+ });
67
82
  process.exit(result.status || 0);
68
83
  }
69
84
  }
@@ -87,7 +102,8 @@ const main = defineCommand({
87
102
  changed: () => import("./commands/changed.mjs").then(m => m.changedCommand)
88
103
  },
89
104
  async run() {
90
- if (!(process.argv.length > 2)) {
105
+ const hasArgs = process.argv.length > 2;
106
+ if (!hasArgs) {
91
107
  const {
92
108
  listAllScripts
93
109
  } = await import("./utils/script-listing.mjs");
@@ -1 +1 @@
1
- {"version":3,"names":["spawnSync","existsSync","statSync","join","defineCommand","runMain","isScriptCategory","name","scriptsDir","process","cwd","categoryPath","isDirectory","findLocalScript","normalizedName","replace","ext","scriptPath","isLocalScript","findBuiltInScript","resolved","import","meta","resolve","packageJsonPath","URL","pathname","packageRoot","srcPath","isBuiltInScript","isShorthand","firstArg","argv","includes","resolvedScriptName","restArgs","slice","subScriptIdx","findIndex","a","startsWith","subScript","splice","hasHelp","flagArgs","filter","result","stdio","shell","exit","status","main","version","description","subCommands","onboard","then","m","onboardCommand","docs","docsCommand","env:setup","envSetupCommand","run","runCommand","run-all","runAllCommand","script","scriptCommand","skills","skillsCommand","sync","syncCommand","changed","changedCommand","length","listAllScripts"],"sources":["../../src/cli.ts"],"sourcesContent":[null],"mappings":";AAOA,SAASA,SAAA,QAAiB;AAC1B,SAASC,UAAA,EAAYC,QAAA,QAAgB;AACrC,SAASC,IAAA,QAAY;AAErB,SAASC,aAAA,EAAeC,OAAA,QAAe;AAGvC,SAASC,iBAAiBC,IAAA,EAAuB;EAC/C,MAAMC,UAAA,GAAaL,IAAA,CAAKM,OAAA,CAAQC,GAAA,CAAI,GAAG,SAAS;IAC1CC,YAAA,GAAeR,IAAA,CAAKK,UAAA,EAAYD,IAAI;EAE1C,IAAI;IACF,OAAON,UAAA,CAAWU,YAAY,KAAKT,QAAA,CAASS,YAAY,EAAEC,WAAA,CAAY;EACxE,QAAQ;IACN,OAAO;EACT;AACF;AAGA,SAASC,gBAAgBN,IAAA,EAA6B;EACpD,MAAMC,UAAA,GAAaL,IAAA,CAAKM,OAAA,CAAQC,GAAA,CAAI,GAAG,SAAS;IAC1CI,cAAA,GAAiBP,IAAA,CAAKQ,OAAA,CAAQ,MAAM,GAAG;EAE7C,WAAWC,GAAA,IAAO,CAAC,OAAO,OAAO,EAAE,GAAG;IACpC,MAAMC,UAAA,GAAad,IAAA,CAAKK,UAAA,EAAY,GAAGM,cAAc,GAAGE,GAAG,EAAE;IAC7D,IAAIf,UAAA,CAAWgB,UAAU,GACvB,OAAOA,UAAA;EAEX;EAEA,OAAO;AACT;AAEA,SAASC,cAAcX,IAAA,EAAuB;EAC5C,OAAOM,eAAA,CAA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
1
+ {"version":3,"names":["spawnSync","existsSync","statSync","join","defineCommand","runMain","isScriptCategory","name","scriptsDir","process","cwd","categoryPath","isDirectory","findLocalScript","normalizedName","replace","ext","scriptPath","isLocalScript","findBuiltInScript","resolved","import","meta","resolve","packageJsonPath","URL","pathname","packageRoot","srcPath","isBuiltInScript","isShorthand","firstArg","argv","builtInCommands","includes","resolvedScriptName","restArgs","slice","subScriptIdx","findIndex","a","startsWith","subScript","splice","hasHelp","flagArgs","filter","result","stdio","shell","exit","status","main","version","description","subCommands","onboard","then","m","onboardCommand","docs","docsCommand","env:setup","envSetupCommand","run","runCommand","run-all","runAllCommand","script","scriptCommand","skills","skillsCommand","sync","syncCommand","changed","changedCommand","hasArgs","length","listAllScripts"],"sources":["../../src/cli.ts"],"sourcesContent":[null],"mappings":";AAOA,SAASA,SAAA,QAAiB;AAC1B,SAASC,UAAA,EAAYC,QAAA,QAAgB;AACrC,SAASC,IAAA,QAAY;AAErB,SAASC,aAAA,EAAeC,OAAA,QAAe;AAGvC,SAASC,iBAAiBC,IAAA,EAAuB;EAC/C,MAAMC,UAAA,GAAaL,IAAA,CAAKM,OAAA,CAAQC,GAAA,CAAI,GAAG,SAAS;EAChD,MAAMC,YAAA,GAAeR,IAAA,CAAKK,UAAA,EAAYD,IAAI;EAE1C,IAAI;IACF,OAAON,UAAA,CAAWU,YAAY,KAAKT,QAAA,CAASS,YAAY,EAAEC,WAAA,CAAY;EACxE,QAAQ;IACN,OAAO;EACT;AACF;AAGA,SAASC,gBAAgBN,IAAA,EAA6B;EACpD,MAAMC,UAAA,GAAaL,IAAA,CAAKM,OAAA,CAAQC,GAAA,CAAI,GAAG,SAAS;EAChD,MAAMI,cAAA,GAAiBP,IAAA,CAAKQ,OAAA,CAAQ,MAAM,GAAG;EAE7C,WAAWC,GAAA,IAAO,CAAC,OAAO,OAAO,EAAE,GAAG;IACpC,MAAMC,UAAA,GAAad,IAAA,CAAKK,UAAA,EAAY,GAAGM,cAAc,GAAGE,GAAG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AAMA,CAAA,CAAEe,WAAW;IAC/DC,OAAA,EAASA,CAAA,KAAM,OAAO,wBAAoB,EAAEjB,IAAA,CAAMC,CAAA,IAAMA,CAAA,CAAEiB,cAAc;EAC1E;EACA,MAAMX,IAAA,EAAM;IACV,MAAMY,OAAA,GAAUnE,OAAA,CAAQuB,IAAA,CAAK6C,MAAA,GAAS;IACtC,IAAI,CAACD,OAAA,EAAS;MACZ,MAAM;QAAEE;MAAe,IAAI,MAAM,OAAO,4BAAwB;MAChE,MAAMA,cAAA,CAAe;IACvB;EACF;AACF,CAAC;AAEDzE,OAAA,CAAQ+C,IAAI","ignoreList":[]}
@@ -3,23 +3,25 @@ import { existsSync, readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { defineCommand } from "citty";
5
5
  import pc from "picocolors";
6
- const UPSTREAM_REPO = "tamagui/takeout2",
7
- UPSTREAM_REMOTE = "takeout-upstream",
8
- TAKEOUT_FILE = ".takeout",
9
- COMMIT_TYPE_ORDER = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci"];
6
+ const UPSTREAM_REPO = "tamagui/takeout2";
7
+ const UPSTREAM_REMOTE = "takeout-upstream";
8
+ const TAKEOUT_FILE = ".takeout";
9
+ const COMMIT_TYPE_ORDER = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci"];
10
10
  function readTakeoutConfig() {
11
11
  const configPath = join(process.cwd(), TAKEOUT_FILE);
12
- if (!existsSync(configPath)) return null;
12
+ if (!existsSync(configPath)) {
13
+ return null;
14
+ }
13
15
  try {
14
- const content = readFileSync(configPath, "utf-8"),
15
- config = {};
16
- for (const line of content.split(`
17
- `)) {
16
+ const content = readFileSync(configPath, "utf-8");
17
+ const config = {};
18
+ for (const line of content.split("\n")) {
18
19
  const trimmed = line.trim();
19
20
  if (trimmed.startsWith("#") || !trimmed) continue;
20
- const [key, ...valueParts] = trimmed.split("="),
21
- value = valueParts.join("=").trim();
22
- key === "sha" && (config.sha = value), key === "date" && (config.date = value);
21
+ const [key, ...valueParts] = trimmed.split("=");
22
+ const value = valueParts.join("=").trim();
23
+ if (key === "sha") config.sha = value;
24
+ if (key === "date") config.date = value;
23
25
  }
24
26
  return config;
25
27
  } catch {
@@ -30,7 +32,9 @@ function parseConventionalCommit(message) {
30
32
  const match = message.match(/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/);
31
33
  if (!match) return null;
32
34
  const [, type, scope, breaking, msg] = match;
33
- return !type || !["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci", "build", "style"].includes(type) ? null : {
35
+ const validTypes = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci", "build", "style"];
36
+ if (!type || !validTypes.includes(type)) return null;
37
+ return {
34
38
  type,
35
39
  scope,
36
40
  message: msg || message,
@@ -39,35 +43,43 @@ function parseConventionalCommit(message) {
39
43
  }
40
44
  function ensureUpstreamRemote() {
41
45
  try {
42
- return execSync("git remote", {
46
+ const remotes = execSync("git remote", {
43
47
  encoding: "utf-8"
44
- }).includes(UPSTREAM_REMOTE) || (console.info(pc.dim(` adding ${UPSTREAM_REMOTE} remote...`)), execSync(`git remote add ${UPSTREAM_REMOTE} git@github.com:${UPSTREAM_REPO}.git`, {
45
- stdio: "pipe"
46
- })), console.info(pc.dim(` fetching from ${UPSTREAM_REMOTE}...`)), execSync(`git fetch ${UPSTREAM_REMOTE} --quiet`, {
48
+ });
49
+ if (!remotes.includes(UPSTREAM_REMOTE)) {
50
+ console.info(pc.dim(` adding ${UPSTREAM_REMOTE} remote...`));
51
+ execSync(`git remote add ${UPSTREAM_REMOTE} git@github.com:${UPSTREAM_REPO}.git`, {
52
+ stdio: "pipe"
53
+ });
54
+ }
55
+ console.info(pc.dim(` fetching from ${UPSTREAM_REMOTE}...`));
56
+ execSync(`git fetch ${UPSTREAM_REMOTE} --quiet`, {
47
57
  stdio: "pipe"
48
- }), !0;
58
+ });
59
+ return true;
49
60
  } catch (err) {
50
- return console.error(pc.red(`failed to setup upstream remote: ${err}`)), !1;
61
+ console.error(pc.red(`failed to setup upstream remote: ${err}`));
62
+ return false;
51
63
  }
52
64
  }
53
65
  function getCommitsBetween(fromSha, toRef) {
54
66
  const commits = [];
55
67
  try {
56
- const lines = execSync(`git log ${fromSha}..${toRef} --pretty=format:"%H|%ad|%s" --date=short 2>/dev/null`, {
68
+ const result = execSync(`git log ${fromSha}..${toRef} --pretty=format:"%H|%ad|%s" --date=short 2>/dev/null`, {
57
69
  encoding: "utf-8",
58
- maxBuffer: 10485760
59
- }).trim().split(`
60
- `).filter(Boolean);
70
+ maxBuffer: 10 * 1024 * 1024
71
+ });
72
+ const lines = result.trim().split("\n").filter(Boolean);
61
73
  for (const line of lines) {
62
- const [hash = "", date = "", ...messageParts] = line.split("|"),
63
- message = messageParts.join("|"),
64
- parsed = parseConventionalCommit(message);
74
+ const [hash = "", date = "", ...messageParts] = line.split("|");
75
+ const message = messageParts.join("|");
76
+ const parsed = parseConventionalCommit(message);
65
77
  commits.push({
66
78
  hash: hash.slice(0, 7),
67
79
  type: parsed?.type || "other",
68
80
  scope: parsed?.scope,
69
81
  message: parsed?.message || message,
70
- breaking: parsed?.breaking || !1,
82
+ breaking: parsed?.breaking || false,
71
83
  date
72
84
  });
73
85
  }
@@ -82,53 +94,56 @@ function formatChangelog(commits) {
82
94
  const grouped = /* @__PURE__ */new Map();
83
95
  for (const commit of commits) {
84
96
  const existing = grouped.get(commit.type) || [];
85
- existing.push(commit), grouped.set(commit.type, existing);
97
+ existing.push(commit);
98
+ grouped.set(commit.type, existing);
86
99
  }
87
100
  const sortedTypes = Array.from(grouped.keys()).sort((a, b) => {
88
- const aIdx = COMMIT_TYPE_ORDER.indexOf(a),
89
- bIdx = COMMIT_TYPE_ORDER.indexOf(b);
90
- return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
91
- }),
92
- breakingChanges = commits.filter(c => c.breaking);
101
+ const aIdx = COMMIT_TYPE_ORDER.indexOf(a);
102
+ const bIdx = COMMIT_TYPE_ORDER.indexOf(b);
103
+ return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
104
+ });
105
+ const breakingChanges = commits.filter(c => c.breaking);
93
106
  if (breakingChanges.length > 0) {
94
- console.info(), console.info(pc.red(pc.bold(" BREAKING CHANGES")));
107
+ console.info();
108
+ console.info(pc.red(pc.bold(" BREAKING CHANGES")));
95
109
  for (const commit of breakingChanges) {
96
110
  const scope = commit.scope ? pc.cyan(`(${commit.scope})`) : "";
97
111
  console.info(` ${pc.red("!")} ${scope} ${commit.message} ${pc.dim(`(${commit.hash})`)}`);
98
112
  }
99
113
  }
100
114
  const typeLabels = {
101
- feat: "Features",
102
- fix: "Bug Fixes",
103
- perf: "Performance",
104
- refactor: "Refactoring",
105
- docs: "Documentation",
106
- chore: "Maintenance",
107
- test: "Tests",
108
- ci: "CI",
109
- build: "Build",
110
- style: "Style",
111
- other: "Other"
112
- },
113
- typeColors = {
114
- feat: pc.green,
115
- fix: pc.yellow,
116
- perf: pc.magenta,
117
- refactor: pc.blue,
118
- docs: pc.dim,
119
- chore: pc.dim,
120
- test: pc.dim,
121
- ci: pc.dim,
122
- build: pc.dim,
123
- style: pc.dim,
124
- other: pc.white
125
- };
115
+ feat: "Features",
116
+ fix: "Bug Fixes",
117
+ perf: "Performance",
118
+ refactor: "Refactoring",
119
+ docs: "Documentation",
120
+ chore: "Maintenance",
121
+ test: "Tests",
122
+ ci: "CI",
123
+ build: "Build",
124
+ style: "Style",
125
+ other: "Other"
126
+ };
127
+ const typeColors = {
128
+ feat: pc.green,
129
+ fix: pc.yellow,
130
+ perf: pc.magenta,
131
+ refactor: pc.blue,
132
+ docs: pc.dim,
133
+ chore: pc.dim,
134
+ test: pc.dim,
135
+ ci: pc.dim,
136
+ build: pc.dim,
137
+ style: pc.dim,
138
+ other: pc.white
139
+ };
126
140
  for (const type of sortedTypes) {
127
141
  const typeCommits = grouped.get(type).filter(c => !c.breaking);
128
142
  if (typeCommits.length === 0) continue;
129
- const label = typeLabels[type] || type,
130
- color = typeColors[type] || pc.white;
131
- console.info(), console.info(color(pc.bold(` ${label}`)));
143
+ const label = typeLabels[type] || type;
144
+ const color = typeColors[type] || pc.white;
145
+ console.info();
146
+ console.info(color(pc.bold(` ${label}`)));
132
147
  for (const commit of typeCommits) {
133
148
  const scope = commit.scope ? pc.cyan(`(${commit.scope}) `) : "";
134
149
  console.info(` ${pc.dim("-")} ${scope}${commit.message} ${pc.dim(`(${commit.hash})`)}`);
@@ -153,25 +168,46 @@ const changedCommand = defineCommand({
153
168
  async run({
154
169
  args
155
170
  }) {
156
- console.info(), console.info(pc.bold(pc.cyan("Takeout Changes"))), console.info();
171
+ console.info();
172
+ console.info(pc.bold(pc.cyan("Takeout Changes")));
173
+ console.info();
157
174
  let fromSha = args.from;
158
175
  const config = readTakeoutConfig();
159
176
  if (!fromSha) {
160
177
  if (!config?.sha) {
161
- console.info(pc.yellow("No .takeout file found with last sync SHA.")), console.info(), console.info(pc.dim("Either:")), console.info(pc.dim(" 1. Create a .takeout file with: sha=<commit-sha>")), console.info(pc.dim(" 2. Run with --from <sha> to specify starting point")), console.info(pc.dim(" 3. Run `tko sync` to sync and create the file")), console.info();
178
+ console.info(pc.yellow("No .takeout file found with last sync SHA."));
179
+ console.info();
180
+ console.info(pc.dim("Either:"));
181
+ console.info(pc.dim(" 1. Create a .takeout file with: sha=<commit-sha>"));
182
+ console.info(pc.dim(" 2. Run with --from <sha> to specify starting point"));
183
+ console.info(pc.dim(" 3. Run `tko sync` to sync and create the file"));
184
+ console.info();
162
185
  return;
163
186
  }
164
187
  fromSha = config.sha;
165
188
  }
166
- if (!ensureUpstreamRemote()) return;
189
+ if (!ensureUpstreamRemote()) {
190
+ return;
191
+ }
167
192
  const toRef = args.to || `${UPSTREAM_REMOTE}/main`;
168
- console.info(pc.dim(` from: ${fromSha.slice(0, 7)}`)), console.info(pc.dim(` to: ${toRef}`)), config?.date && console.info(pc.dim(` last sync: ${config.date}`));
193
+ console.info(pc.dim(` from: ${fromSha.slice(0, 7)}`));
194
+ console.info(pc.dim(` to: ${toRef}`));
195
+ if (config?.date) {
196
+ console.info(pc.dim(` last sync: ${config.date}`));
197
+ }
169
198
  const commits = getCommitsBetween(fromSha, toRef);
170
199
  if (commits.length === 0) {
171
- console.info(), console.info(pc.green("\u2713 Already up to date with upstream!")), console.info();
200
+ console.info();
201
+ console.info(pc.green("\u2713 Already up to date with upstream!"));
202
+ console.info();
172
203
  return;
173
204
  }
174
- console.info(), console.info(pc.bold(`${commits.length} commit${commits.length === 1 ? "" : "s"} since last sync:`)), formatChangelog(commits), console.info(), console.info(pc.dim("Run `tko sync` to sync these changes into your fork.")), console.info();
205
+ console.info();
206
+ console.info(pc.bold(`${commits.length} commit${commits.length === 1 ? "" : "s"} since last sync:`));
207
+ formatChangelog(commits);
208
+ console.info();
209
+ console.info(pc.dim("Run `tko sync` to sync these changes into your fork."));
210
+ console.info();
175
211
  }
176
212
  });
177
213
  export { changedCommand };