rust-just 1.35.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/README.md +44 -4003
- package/lib/index.mjs +60 -0
- package/package.json +14 -27
- package/lib/cjs/index.cjs +0 -96
- package/lib/cjs/index.cjs.map +0 -1
- package/lib/cjs/index.d.cts +0 -103
- package/lib/cli/cli.js +0 -100
- package/lib/esm/index.d.ts +0 -103
- package/lib/esm/index.js +0 -94
- package/lib/esm/index.js.map +0 -1
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { platform, arch } from 'os';
|
|
5
|
+
import yargs from 'yargs/yargs';
|
|
6
|
+
import { hideBin } from 'yargs/helpers';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
async function getExePath() {
|
|
11
|
+
const platform$1 = platform();
|
|
12
|
+
const arch$1 = arch();
|
|
13
|
+
let os = platform$1;
|
|
14
|
+
let extension = "";
|
|
15
|
+
if (platform$1 === "win32" || platform$1 === "cygwin") {
|
|
16
|
+
os = "windows";
|
|
17
|
+
extension = ".exe";
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return import.meta.resolve(
|
|
21
|
+
`rust-just-${os}-${arch$1}/bin/just${extension}`
|
|
22
|
+
);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Couldn't find just binary inside node_modules for ${os}-${arch$1} (${e})`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
__name(getExePath, "getExePath");
|
|
30
|
+
function safeParse(jsonString) {
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(jsonString);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error("Invalid JSON format in --options");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
__name(safeParse, "safeParse");
|
|
39
|
+
async function run() {
|
|
40
|
+
const exePath = await getExePath();
|
|
41
|
+
const argv = yargs(hideBin(process.argv)).option("execaoptions", {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Execa options in JSON format"
|
|
44
|
+
}).parserConfiguration({
|
|
45
|
+
"unknown-options-as-args": true
|
|
46
|
+
}).help(false).version(false).parse();
|
|
47
|
+
const args = argv._;
|
|
48
|
+
let execaOptions = {
|
|
49
|
+
stdio: "inherit",
|
|
50
|
+
reject: false
|
|
51
|
+
};
|
|
52
|
+
if (argv.execaoptions) {
|
|
53
|
+
const userOptions = safeParse(argv.execaoptions);
|
|
54
|
+
execaOptions = { ...execaOptions, ...userOptions };
|
|
55
|
+
}
|
|
56
|
+
const processResult = await execa(fileURLToPath(exePath), args, execaOptions);
|
|
57
|
+
process.exit(processResult.exitCode ?? 0);
|
|
58
|
+
}
|
|
59
|
+
__name(run, "run");
|
|
60
|
+
void run();
|
package/package.json
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-just",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "🤖 Just a command runner",
|
|
5
|
-
"
|
|
6
|
-
"main": "lib/cjs/index.d.cts",
|
|
7
|
-
"module": "lib/esm/index.d.ts",
|
|
8
|
-
"types": "lib/cjs/index.d.cts",
|
|
9
|
-
"bin": "lib/cli/cli.js",
|
|
5
|
+
"bin": "lib/index.mjs",
|
|
10
6
|
"exports": {
|
|
11
|
-
"./cli": {
|
|
12
|
-
"import": "./lib/cli/cli.js"
|
|
13
|
-
},
|
|
14
7
|
".": {
|
|
15
|
-
"import":
|
|
16
|
-
"types": "./lib/esm/index.d.ts",
|
|
17
|
-
"default": "./lib/esm/index.js"
|
|
18
|
-
},
|
|
19
|
-
"require": {
|
|
20
|
-
"types": "./lib/cjs/index.d.cts",
|
|
21
|
-
"default": "./lib/cjs/index.cjs"
|
|
22
|
-
}
|
|
8
|
+
"import": "./lib/index.mjs"
|
|
23
9
|
}
|
|
24
10
|
},
|
|
25
11
|
"files": [
|
|
@@ -30,7 +16,7 @@
|
|
|
30
16
|
"lint": "eslint .",
|
|
31
17
|
"lint:fix": "eslint . --fix",
|
|
32
18
|
"build": "tsup",
|
|
33
|
-
"dev": "yarn build && node lib/
|
|
19
|
+
"dev": "yarn build && node lib/index.mjs"
|
|
34
20
|
},
|
|
35
21
|
"repository": {
|
|
36
22
|
"type": "git",
|
|
@@ -49,9 +35,10 @@
|
|
|
49
35
|
"bugs": {
|
|
50
36
|
"url": "https://github.com/casey/just/issues"
|
|
51
37
|
},
|
|
52
|
-
"homepage": "https://github.com/
|
|
38
|
+
"homepage": "https://github.com/gnpaone/rust-just/tree/master/npm#readme",
|
|
53
39
|
"dependencies": {
|
|
54
|
-
"execa": "^
|
|
40
|
+
"execa": "^9.4.1",
|
|
41
|
+
"yargs": "^17.7.2"
|
|
55
42
|
},
|
|
56
43
|
"devDependencies": {
|
|
57
44
|
"@types/node": "^20.11.22",
|
|
@@ -62,13 +49,13 @@
|
|
|
62
49
|
"typescript": "^5.3.3"
|
|
63
50
|
},
|
|
64
51
|
"optionalDependencies": {
|
|
65
|
-
"rust-just-darwin-arm64": "1.
|
|
66
|
-
"rust-just-darwin-x64": "1.
|
|
67
|
-
"rust-just-linux-arm": "1.
|
|
68
|
-
"rust-just-linux-arm64": "1.
|
|
69
|
-
"rust-just-linux-x64": "1.
|
|
70
|
-
"rust-just-windows-arm64": "1.
|
|
71
|
-
"rust-just-windows-x64": "1.
|
|
52
|
+
"rust-just-darwin-arm64": "1.37.0",
|
|
53
|
+
"rust-just-darwin-x64": "1.37.0",
|
|
54
|
+
"rust-just-linux-arm": "1.37.0",
|
|
55
|
+
"rust-just-linux-arm64": "1.37.0",
|
|
56
|
+
"rust-just-linux-x64": "1.37.0",
|
|
57
|
+
"rust-just-windows-arm64": "1.37.0",
|
|
58
|
+
"rust-just-windows-x64": "1.37.0"
|
|
72
59
|
},
|
|
73
60
|
"eslintConfig": {
|
|
74
61
|
"extends": [
|
package/lib/cjs/index.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var execa = require('execa');
|
|
4
|
-
var url = require('url');
|
|
5
|
-
var os = require('os');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
async function getExePath() {
|
|
10
|
-
const platform = os.platform();
|
|
11
|
-
const arch = os.arch();
|
|
12
|
-
let os$1 = platform;
|
|
13
|
-
let extension = "";
|
|
14
|
-
if (platform === "win32" || platform === "cygwin") {
|
|
15
|
-
os$1 = "windows";
|
|
16
|
-
extension = ".exe";
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
return undefined(
|
|
20
|
-
`rust-just-${os$1}-${arch}/bin/just${extension}`
|
|
21
|
-
);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Couldn't find just binary inside node_modules for ${os$1}-${arch} (${e})`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
__name(getExePath, "getExePath");
|
|
29
|
-
|
|
30
|
-
// src/optionsToStringArgs.ts
|
|
31
|
-
function optionsToStringArgs(options) {
|
|
32
|
-
const args = [];
|
|
33
|
-
for (const [key, value] of Object.entries(options)) {
|
|
34
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
35
|
-
if ((key === "list" || key === "shellCommand" || key === "command") && typeof value === "string" && value.trim().length > 0) {
|
|
36
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
37
|
-
if (values.length > 0) {
|
|
38
|
-
args.push(`--${hyphenCaseKey}`, ...values);
|
|
39
|
-
}
|
|
40
|
-
} else if (key === "set" && typeof value === "string") {
|
|
41
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
42
|
-
if (values.length === 2) {
|
|
43
|
-
args.push(`--${hyphenCaseKey}`, values[0], values[1]);
|
|
44
|
-
}
|
|
45
|
-
} else if (key === "verbose" && typeof value === "number") {
|
|
46
|
-
for (let i = 0; i < value; i++) {
|
|
47
|
-
args.push(`--${hyphenCaseKey}`);
|
|
48
|
-
}
|
|
49
|
-
} else if (value === true) {
|
|
50
|
-
args.push(`--${hyphenCaseKey}`);
|
|
51
|
-
} else if (value === false || value === null) {
|
|
52
|
-
continue;
|
|
53
|
-
} else {
|
|
54
|
-
args.push(`--${hyphenCaseKey}`, String(value));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return args;
|
|
58
|
-
}
|
|
59
|
-
__name(optionsToStringArgs, "optionsToStringArgs");
|
|
60
|
-
|
|
61
|
-
// src/index.ts
|
|
62
|
-
function isOptionKey(arg, optionsKeys) {
|
|
63
|
-
return optionsKeys.includes(arg);
|
|
64
|
-
}
|
|
65
|
-
__name(isOptionKey, "isOptionKey");
|
|
66
|
-
async function runJust(argsOrOptions, execaOptions) {
|
|
67
|
-
const exePath = await getExePath();
|
|
68
|
-
let args = [];
|
|
69
|
-
const optionsKeys = Object.keys({ ...new class {
|
|
70
|
-
}() });
|
|
71
|
-
if (Array.isArray(argsOrOptions)) {
|
|
72
|
-
args = argsOrOptions;
|
|
73
|
-
} else {
|
|
74
|
-
const knownArgs = optionsToStringArgs(argsOrOptions);
|
|
75
|
-
for (const [key, value] of Object.entries(argsOrOptions)) {
|
|
76
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
77
|
-
if (!isOptionKey(hyphenCaseKey, optionsKeys)) {
|
|
78
|
-
if (value === true) {
|
|
79
|
-
args.push(key);
|
|
80
|
-
} else if (value !== false && value !== null) {
|
|
81
|
-
args.push(key, String(value));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
args = [...knownArgs, ...args];
|
|
86
|
-
}
|
|
87
|
-
return execa.execa(url.fileURLToPath(exePath), args, {
|
|
88
|
-
stdio: "inherit",
|
|
89
|
-
...execaOptions
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
__name(runJust, "runJust");
|
|
93
|
-
|
|
94
|
-
exports.runJust = runJust;
|
|
95
|
-
//# sourceMappingURL=out.js.map
|
|
96
|
-
//# sourceMappingURL=index.cjs.map
|
package/lib/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/getExePath.ts","../../src/optionsToStringArgs.ts"],"names":[],"mappings":"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","sourcesContent":["import { execa, type Options as ExecaOptions, type ExecaReturnValue, } from \"execa\";\nimport { fileURLToPath } from \"node:url\";\nimport { getExePath } from \"./getExePath.js\";\nimport type { Options } from \"./options.js\";\nimport { optionsToStringArgs } from \"./optionsToStringArgs.js\";\n\nexport type { Options } from \"./options.js\";\n\n/**\n * Utility function to check if an argument exists in the predefined Options.\n * @param arg - The argument to check\n * @param optionsKeys - The list of keys from the Options type\n * @returns True if the argument exists in Options, false otherwise\n */\nfunction isOptionKey(arg: string, optionsKeys: string[]): boolean {\n return optionsKeys.includes(arg);\n}\n/**\n * Runs `just` with the provided options as a JavaScript object.\n *\n * @param options - The options to pass to `just`.\n * These get transformed into an array strings.\n * - Values that are `true` will be passed as flags (`--flag`).\n * - Values that are `false` or `null` will be ignored.\n * - All other values will be passed as options (`--option value`).\n *\n * @param execaOptions - Options to pass to {@link execa}.\n */\nexport async function runJust(options: Options, execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>>;\n/**\n * Runs the `just` with the provided arguments.\n *\n * @param args - The arguments to pass to `just`.\n * These should be in an array of string format.\n * Every option and their value should be its own entry in the array.\n *\n * @param execaOptions - Options to pass to {@link execa}.\n *\n * @returns A promise that resolves when the `just` has finished running.\n *\n * @example\n * Options with values\n * ```typescript\n * await runJust([\"--evaluate\", \"foo\"]);\n * ```\n * \n * @example\n * Options with array type values\n * ```typescript\n * await runJust([\"--set\", \"'<VARIABLE>' '<VALUE>'\"]);\n * ```\n *\n * @example\n * Boolean flags\n * ```typescript\n * await runJust([\"--version\"]);\n * ```\n * \n * @example\n * Justfile functions\n * ```typescript\n * await runJust([\"foo\"]);\n * ```\n */\nexport async function runJust(args: string[], execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>>;\nexport async function runJust(argsOrOptions: Options | string[], execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>> {\n const exePath = await getExePath();\n let args: string[] = [];\n\n const optionsKeys = Object.keys({ ...new (class implements Options {}) });\n\n if (Array.isArray(argsOrOptions)) {\n args = argsOrOptions;\n } else {\n const knownArgs = optionsToStringArgs(argsOrOptions);\n\n for (const [key, value] of Object.entries(argsOrOptions)) {\n const hyphenCaseKey = key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\n if (!isOptionKey(hyphenCaseKey, optionsKeys)) {\n if (value === true) {\n args.push(key);\n } else if (value !== false && value !== null) {\n args.push(key, String(value));\n }\n }\n }\n\n args = [...knownArgs, ...args];\n }\n\n return execa(fileURLToPath(exePath), args, {\n stdio: \"inherit\",\n ...execaOptions,\n });\n}\n","import { arch as getArch, platform as getPlatform } from \"os\";\n\n/**\n * Returns the executable path for just located inside node_modules\n * The naming convention is just-${os}-${arch}\n * If the platform is `win32` or `cygwin`, executable will include a `.exe` extension\n * @see https://nodejs.org/api/os.html#osarch\n * @see https://nodejs.org/api/os.html#osplatform\n * @example \"x/xx/node_modules/just-darwin-arm64\"\n */\nexport async function getExePath() {\n const platform = getPlatform();\n const arch = getArch();\n\n let os = platform as string;\n let extension = \"\";\n\n if (platform === \"win32\" || platform === \"cygwin\") {\n os = \"windows\";\n extension = \".exe\";\n }\n\n try {\n // Since the bin will be located inside `node_modules`, we can simply call import.meta.resolve\n return import.meta.resolve(\n `rust-just-${os}-${arch}/bin/just${extension}`,\n );\n } catch (e) {\n throw new Error(\n `Couldn't find just binary inside node_modules for ${os}-${arch} (${e})`,\n );\n }\n}\n","import type { Options } from \"./options.js\";\n\n/**\n * Transforms a JavaScript object of options into an array\n * of strings that can be passed to {@link execa} for calling `just`\n *\n * @param options The options to transform\n * @returns The options as an array of strings\n */\nexport function optionsToStringArgs(options: Options): string[] {\n const args: string[] = [];\n\n for (const [key, value] of Object.entries(options)) {\n const hyphenCaseKey = key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\n if (\n (key === 'list' || key === 'shellCommand' || key === 'command') &&\n typeof value === 'string' &&\n value.trim().length > 0\n ) {\n const values = value.match(/'([^']+)'/g)?.map(v => v.replace(/'/g, '')) || [];\n if (values.length > 0) {\n args.push(`--${hyphenCaseKey}`, ...values);\n }\n } else if (key === 'set' && typeof value === 'string') {\n const values = value.match(/'([^']+)'/g)?.map(v => v.replace(/'/g, '')) || [];\n if (values.length === 2) {\n args.push(`--${hyphenCaseKey}`, values[0], values[1]);\n }\n } else if (key === 'verbose' && typeof value === 'number') {\n for (let i = 0; i < value; i++) {\n args.push(`--${hyphenCaseKey}`);\n }\n } else if (value === true) {\n args.push(`--${hyphenCaseKey}`);\n } else if (value === false || value === null) {\n continue;\n } else {\n args.push(`--${hyphenCaseKey}`, String(value));\n }\n }\n\n return args;\n}\n"]}
|
package/lib/cjs/index.d.cts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Options as Options$1, ExecaReturnValue } from 'execa';
|
|
2
|
-
|
|
3
|
-
type Options = Partial<{
|
|
4
|
-
help: boolean;
|
|
5
|
-
version: boolean;
|
|
6
|
-
verbose: number;
|
|
7
|
-
init: boolean | string;
|
|
8
|
-
check: boolean;
|
|
9
|
-
chooser: string;
|
|
10
|
-
clearShellArgs: boolean;
|
|
11
|
-
color: string;
|
|
12
|
-
commandColor: string;
|
|
13
|
-
dotenvFilename: string;
|
|
14
|
-
dotenvPath: string;
|
|
15
|
-
dryRun: boolean;
|
|
16
|
-
dumpFormat: string;
|
|
17
|
-
globalJustfile: boolean;
|
|
18
|
-
highlight: boolean;
|
|
19
|
-
justfile: string;
|
|
20
|
-
listHeading: string;
|
|
21
|
-
listPrefix: string;
|
|
22
|
-
listSubmodules: boolean;
|
|
23
|
-
noAliases: boolean;
|
|
24
|
-
noDeps: boolean;
|
|
25
|
-
noDotenv: boolean;
|
|
26
|
-
noHighlight: boolean;
|
|
27
|
-
quiet: boolean;
|
|
28
|
-
set: string;
|
|
29
|
-
shell: string;
|
|
30
|
-
shellArg: string;
|
|
31
|
-
shellCommand: string;
|
|
32
|
-
timestamp: boolean;
|
|
33
|
-
timestampFormat: string;
|
|
34
|
-
unsorted: boolean;
|
|
35
|
-
unstable: boolean;
|
|
36
|
-
workingDirectory: string;
|
|
37
|
-
yes: boolean;
|
|
38
|
-
changelog: boolean;
|
|
39
|
-
choose: boolean;
|
|
40
|
-
command: string;
|
|
41
|
-
completions: string;
|
|
42
|
-
dump: boolean;
|
|
43
|
-
edit: boolean;
|
|
44
|
-
evaluate: boolean;
|
|
45
|
-
fmt: boolean;
|
|
46
|
-
groups: boolean;
|
|
47
|
-
list: string;
|
|
48
|
-
man: boolean;
|
|
49
|
-
show: string;
|
|
50
|
-
summary: boolean;
|
|
51
|
-
variables: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Runs `just` with the provided options as a JavaScript object.
|
|
56
|
-
*
|
|
57
|
-
* @param options - The options to pass to `just`.
|
|
58
|
-
* These get transformed into an array strings.
|
|
59
|
-
* - Values that are `true` will be passed as flags (`--flag`).
|
|
60
|
-
* - Values that are `false` or `null` will be ignored.
|
|
61
|
-
* - All other values will be passed as options (`--option value`).
|
|
62
|
-
*
|
|
63
|
-
* @param execaOptions - Options to pass to {@link execa}.
|
|
64
|
-
*/
|
|
65
|
-
declare function runJust(options: Options, execaOptions?: Options$1): Promise<ExecaReturnValue<string>>;
|
|
66
|
-
/**
|
|
67
|
-
* Runs the `just` with the provided arguments.
|
|
68
|
-
*
|
|
69
|
-
* @param args - The arguments to pass to `just`.
|
|
70
|
-
* These should be in an array of string format.
|
|
71
|
-
* Every option and their value should be its own entry in the array.
|
|
72
|
-
*
|
|
73
|
-
* @param execaOptions - Options to pass to {@link execa}.
|
|
74
|
-
*
|
|
75
|
-
* @returns A promise that resolves when the `just` has finished running.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* Options with values
|
|
79
|
-
* ```typescript
|
|
80
|
-
* await runJust(["--evaluate", "foo"]);
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* Options with array type values
|
|
85
|
-
* ```typescript
|
|
86
|
-
* await runJust(["--set", "'<VARIABLE>' '<VALUE>'"]);
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* Boolean flags
|
|
91
|
-
* ```typescript
|
|
92
|
-
* await runJust(["--version"]);
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* Justfile functions
|
|
97
|
-
* ```typescript
|
|
98
|
-
* await runJust(["foo"]);
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
declare function runJust(args: string[], execaOptions?: Options$1): Promise<ExecaReturnValue<string>>;
|
|
102
|
-
|
|
103
|
-
export { type Options, runJust };
|
package/lib/cli/cli.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execa } from 'execa';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { platform, arch } from 'os';
|
|
5
|
-
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
async function getExePath() {
|
|
9
|
-
const platform$1 = platform();
|
|
10
|
-
const arch$1 = arch();
|
|
11
|
-
let os = platform$1;
|
|
12
|
-
let extension = "";
|
|
13
|
-
if (platform$1 === "win32" || platform$1 === "cygwin") {
|
|
14
|
-
os = "windows";
|
|
15
|
-
extension = ".exe";
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
return import.meta.resolve(
|
|
19
|
-
`rust-just-${os}-${arch$1}/bin/just${extension}`
|
|
20
|
-
);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
`Couldn't find just binary inside node_modules for ${os}-${arch$1} (${e})`
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
__name(getExePath, "getExePath");
|
|
28
|
-
|
|
29
|
-
// src/optionsToStringArgs.ts
|
|
30
|
-
function optionsToStringArgs(options) {
|
|
31
|
-
const args = [];
|
|
32
|
-
for (const [key, value] of Object.entries(options)) {
|
|
33
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
34
|
-
if ((key === "list" || key === "shellCommand" || key === "command") && typeof value === "string" && value.trim().length > 0) {
|
|
35
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
36
|
-
if (values.length > 0) {
|
|
37
|
-
args.push(`--${hyphenCaseKey}`, ...values);
|
|
38
|
-
}
|
|
39
|
-
} else if (key === "set" && typeof value === "string") {
|
|
40
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
41
|
-
if (values.length === 2) {
|
|
42
|
-
args.push(`--${hyphenCaseKey}`, values[0], values[1]);
|
|
43
|
-
}
|
|
44
|
-
} else if (key === "verbose" && typeof value === "number") {
|
|
45
|
-
for (let i = 0; i < value; i++) {
|
|
46
|
-
args.push(`--${hyphenCaseKey}`);
|
|
47
|
-
}
|
|
48
|
-
} else if (value === true) {
|
|
49
|
-
args.push(`--${hyphenCaseKey}`);
|
|
50
|
-
} else if (value === false || value === null) {
|
|
51
|
-
continue;
|
|
52
|
-
} else {
|
|
53
|
-
args.push(`--${hyphenCaseKey}`, String(value));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return args;
|
|
57
|
-
}
|
|
58
|
-
__name(optionsToStringArgs, "optionsToStringArgs");
|
|
59
|
-
|
|
60
|
-
// src/index.ts
|
|
61
|
-
function isOptionKey(arg, optionsKeys) {
|
|
62
|
-
return optionsKeys.includes(arg);
|
|
63
|
-
}
|
|
64
|
-
__name(isOptionKey, "isOptionKey");
|
|
65
|
-
async function runJust(argsOrOptions, execaOptions) {
|
|
66
|
-
const exePath = await getExePath();
|
|
67
|
-
let args = [];
|
|
68
|
-
const optionsKeys = Object.keys({ ...new class {
|
|
69
|
-
}() });
|
|
70
|
-
if (Array.isArray(argsOrOptions)) {
|
|
71
|
-
args = argsOrOptions;
|
|
72
|
-
} else {
|
|
73
|
-
const knownArgs = optionsToStringArgs(argsOrOptions);
|
|
74
|
-
for (const [key, value] of Object.entries(argsOrOptions)) {
|
|
75
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
76
|
-
if (!isOptionKey(hyphenCaseKey, optionsKeys)) {
|
|
77
|
-
if (value === true) {
|
|
78
|
-
args.push(key);
|
|
79
|
-
} else if (value !== false && value !== null) {
|
|
80
|
-
args.push(key, String(value));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
args = [...knownArgs, ...args];
|
|
85
|
-
}
|
|
86
|
-
return execa(fileURLToPath(exePath), args, {
|
|
87
|
-
stdio: "inherit",
|
|
88
|
-
...execaOptions
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
__name(runJust, "runJust");
|
|
92
|
-
|
|
93
|
-
// src/cli.ts
|
|
94
|
-
async function run() {
|
|
95
|
-
const args = process.argv.slice(2);
|
|
96
|
-
const processResult = await runJust(args);
|
|
97
|
-
process.exit(processResult.exitCode ?? 0);
|
|
98
|
-
}
|
|
99
|
-
__name(run, "run");
|
|
100
|
-
void run();
|
package/lib/esm/index.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Options as Options$1, ExecaReturnValue } from 'execa';
|
|
2
|
-
|
|
3
|
-
type Options = Partial<{
|
|
4
|
-
help: boolean;
|
|
5
|
-
version: boolean;
|
|
6
|
-
verbose: number;
|
|
7
|
-
init: boolean | string;
|
|
8
|
-
check: boolean;
|
|
9
|
-
chooser: string;
|
|
10
|
-
clearShellArgs: boolean;
|
|
11
|
-
color: string;
|
|
12
|
-
commandColor: string;
|
|
13
|
-
dotenvFilename: string;
|
|
14
|
-
dotenvPath: string;
|
|
15
|
-
dryRun: boolean;
|
|
16
|
-
dumpFormat: string;
|
|
17
|
-
globalJustfile: boolean;
|
|
18
|
-
highlight: boolean;
|
|
19
|
-
justfile: string;
|
|
20
|
-
listHeading: string;
|
|
21
|
-
listPrefix: string;
|
|
22
|
-
listSubmodules: boolean;
|
|
23
|
-
noAliases: boolean;
|
|
24
|
-
noDeps: boolean;
|
|
25
|
-
noDotenv: boolean;
|
|
26
|
-
noHighlight: boolean;
|
|
27
|
-
quiet: boolean;
|
|
28
|
-
set: string;
|
|
29
|
-
shell: string;
|
|
30
|
-
shellArg: string;
|
|
31
|
-
shellCommand: string;
|
|
32
|
-
timestamp: boolean;
|
|
33
|
-
timestampFormat: string;
|
|
34
|
-
unsorted: boolean;
|
|
35
|
-
unstable: boolean;
|
|
36
|
-
workingDirectory: string;
|
|
37
|
-
yes: boolean;
|
|
38
|
-
changelog: boolean;
|
|
39
|
-
choose: boolean;
|
|
40
|
-
command: string;
|
|
41
|
-
completions: string;
|
|
42
|
-
dump: boolean;
|
|
43
|
-
edit: boolean;
|
|
44
|
-
evaluate: boolean;
|
|
45
|
-
fmt: boolean;
|
|
46
|
-
groups: boolean;
|
|
47
|
-
list: string;
|
|
48
|
-
man: boolean;
|
|
49
|
-
show: string;
|
|
50
|
-
summary: boolean;
|
|
51
|
-
variables: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Runs `just` with the provided options as a JavaScript object.
|
|
56
|
-
*
|
|
57
|
-
* @param options - The options to pass to `just`.
|
|
58
|
-
* These get transformed into an array strings.
|
|
59
|
-
* - Values that are `true` will be passed as flags (`--flag`).
|
|
60
|
-
* - Values that are `false` or `null` will be ignored.
|
|
61
|
-
* - All other values will be passed as options (`--option value`).
|
|
62
|
-
*
|
|
63
|
-
* @param execaOptions - Options to pass to {@link execa}.
|
|
64
|
-
*/
|
|
65
|
-
declare function runJust(options: Options, execaOptions?: Options$1): Promise<ExecaReturnValue<string>>;
|
|
66
|
-
/**
|
|
67
|
-
* Runs the `just` with the provided arguments.
|
|
68
|
-
*
|
|
69
|
-
* @param args - The arguments to pass to `just`.
|
|
70
|
-
* These should be in an array of string format.
|
|
71
|
-
* Every option and their value should be its own entry in the array.
|
|
72
|
-
*
|
|
73
|
-
* @param execaOptions - Options to pass to {@link execa}.
|
|
74
|
-
*
|
|
75
|
-
* @returns A promise that resolves when the `just` has finished running.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* Options with values
|
|
79
|
-
* ```typescript
|
|
80
|
-
* await runJust(["--evaluate", "foo"]);
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* Options with array type values
|
|
85
|
-
* ```typescript
|
|
86
|
-
* await runJust(["--set", "'<VARIABLE>' '<VALUE>'"]);
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* Boolean flags
|
|
91
|
-
* ```typescript
|
|
92
|
-
* await runJust(["--version"]);
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* Justfile functions
|
|
97
|
-
* ```typescript
|
|
98
|
-
* await runJust(["foo"]);
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
declare function runJust(args: string[], execaOptions?: Options$1): Promise<ExecaReturnValue<string>>;
|
|
102
|
-
|
|
103
|
-
export { type Options, runJust };
|
package/lib/esm/index.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { platform, arch } from 'os';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
async function getExePath() {
|
|
8
|
-
const platform$1 = platform();
|
|
9
|
-
const arch$1 = arch();
|
|
10
|
-
let os = platform$1;
|
|
11
|
-
let extension = "";
|
|
12
|
-
if (platform$1 === "win32" || platform$1 === "cygwin") {
|
|
13
|
-
os = "windows";
|
|
14
|
-
extension = ".exe";
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
return import.meta.resolve(
|
|
18
|
-
`rust-just-${os}-${arch$1}/bin/just${extension}`
|
|
19
|
-
);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
`Couldn't find just binary inside node_modules for ${os}-${arch$1} (${e})`
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
__name(getExePath, "getExePath");
|
|
27
|
-
|
|
28
|
-
// src/optionsToStringArgs.ts
|
|
29
|
-
function optionsToStringArgs(options) {
|
|
30
|
-
const args = [];
|
|
31
|
-
for (const [key, value] of Object.entries(options)) {
|
|
32
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
33
|
-
if ((key === "list" || key === "shellCommand" || key === "command") && typeof value === "string" && value.trim().length > 0) {
|
|
34
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
35
|
-
if (values.length > 0) {
|
|
36
|
-
args.push(`--${hyphenCaseKey}`, ...values);
|
|
37
|
-
}
|
|
38
|
-
} else if (key === "set" && typeof value === "string") {
|
|
39
|
-
const values = value.match(/'([^']+)'/g)?.map((v) => v.replace(/'/g, "")) || [];
|
|
40
|
-
if (values.length === 2) {
|
|
41
|
-
args.push(`--${hyphenCaseKey}`, values[0], values[1]);
|
|
42
|
-
}
|
|
43
|
-
} else if (key === "verbose" && typeof value === "number") {
|
|
44
|
-
for (let i = 0; i < value; i++) {
|
|
45
|
-
args.push(`--${hyphenCaseKey}`);
|
|
46
|
-
}
|
|
47
|
-
} else if (value === true) {
|
|
48
|
-
args.push(`--${hyphenCaseKey}`);
|
|
49
|
-
} else if (value === false || value === null) {
|
|
50
|
-
continue;
|
|
51
|
-
} else {
|
|
52
|
-
args.push(`--${hyphenCaseKey}`, String(value));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return args;
|
|
56
|
-
}
|
|
57
|
-
__name(optionsToStringArgs, "optionsToStringArgs");
|
|
58
|
-
|
|
59
|
-
// src/index.ts
|
|
60
|
-
function isOptionKey(arg, optionsKeys) {
|
|
61
|
-
return optionsKeys.includes(arg);
|
|
62
|
-
}
|
|
63
|
-
__name(isOptionKey, "isOptionKey");
|
|
64
|
-
async function runJust(argsOrOptions, execaOptions) {
|
|
65
|
-
const exePath = await getExePath();
|
|
66
|
-
let args = [];
|
|
67
|
-
const optionsKeys = Object.keys({ ...new class {
|
|
68
|
-
}() });
|
|
69
|
-
if (Array.isArray(argsOrOptions)) {
|
|
70
|
-
args = argsOrOptions;
|
|
71
|
-
} else {
|
|
72
|
-
const knownArgs = optionsToStringArgs(argsOrOptions);
|
|
73
|
-
for (const [key, value] of Object.entries(argsOrOptions)) {
|
|
74
|
-
const hyphenCaseKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
75
|
-
if (!isOptionKey(hyphenCaseKey, optionsKeys)) {
|
|
76
|
-
if (value === true) {
|
|
77
|
-
args.push(key);
|
|
78
|
-
} else if (value !== false && value !== null) {
|
|
79
|
-
args.push(key, String(value));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
args = [...knownArgs, ...args];
|
|
84
|
-
}
|
|
85
|
-
return execa(fileURLToPath(exePath), args, {
|
|
86
|
-
stdio: "inherit",
|
|
87
|
-
...execaOptions
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
__name(runJust, "runJust");
|
|
91
|
-
|
|
92
|
-
export { runJust };
|
|
93
|
-
//# sourceMappingURL=out.js.map
|
|
94
|
-
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/getExePath.ts","../../src/optionsToStringArgs.ts"],"names":[],"mappings":"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","sourcesContent":["import { execa, type Options as ExecaOptions, type ExecaReturnValue, } from \"execa\";\nimport { fileURLToPath } from \"node:url\";\nimport { getExePath } from \"./getExePath.js\";\nimport type { Options } from \"./options.js\";\nimport { optionsToStringArgs } from \"./optionsToStringArgs.js\";\n\nexport type { Options } from \"./options.js\";\n\n/**\n * Utility function to check if an argument exists in the predefined Options.\n * @param arg - The argument to check\n * @param optionsKeys - The list of keys from the Options type\n * @returns True if the argument exists in Options, false otherwise\n */\nfunction isOptionKey(arg: string, optionsKeys: string[]): boolean {\n return optionsKeys.includes(arg);\n}\n/**\n * Runs `just` with the provided options as a JavaScript object.\n *\n * @param options - The options to pass to `just`.\n * These get transformed into an array strings.\n * - Values that are `true` will be passed as flags (`--flag`).\n * - Values that are `false` or `null` will be ignored.\n * - All other values will be passed as options (`--option value`).\n *\n * @param execaOptions - Options to pass to {@link execa}.\n */\nexport async function runJust(options: Options, execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>>;\n/**\n * Runs the `just` with the provided arguments.\n *\n * @param args - The arguments to pass to `just`.\n * These should be in an array of string format.\n * Every option and their value should be its own entry in the array.\n *\n * @param execaOptions - Options to pass to {@link execa}.\n *\n * @returns A promise that resolves when the `just` has finished running.\n *\n * @example\n * Options with values\n * ```typescript\n * await runJust([\"--evaluate\", \"foo\"]);\n * ```\n * \n * @example\n * Options with array type values\n * ```typescript\n * await runJust([\"--set\", \"'<VARIABLE>' '<VALUE>'\"]);\n * ```\n *\n * @example\n * Boolean flags\n * ```typescript\n * await runJust([\"--version\"]);\n * ```\n * \n * @example\n * Justfile functions\n * ```typescript\n * await runJust([\"foo\"]);\n * ```\n */\nexport async function runJust(args: string[], execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>>;\nexport async function runJust(argsOrOptions: Options | string[], execaOptions?: ExecaOptions): Promise<ExecaReturnValue<string>> {\n const exePath = await getExePath();\n let args: string[] = [];\n\n const optionsKeys = Object.keys({ ...new (class implements Options {}) });\n\n if (Array.isArray(argsOrOptions)) {\n args = argsOrOptions;\n } else {\n const knownArgs = optionsToStringArgs(argsOrOptions);\n\n for (const [key, value] of Object.entries(argsOrOptions)) {\n const hyphenCaseKey = key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\n if (!isOptionKey(hyphenCaseKey, optionsKeys)) {\n if (value === true) {\n args.push(key);\n } else if (value !== false && value !== null) {\n args.push(key, String(value));\n }\n }\n }\n\n args = [...knownArgs, ...args];\n }\n\n return execa(fileURLToPath(exePath), args, {\n stdio: \"inherit\",\n ...execaOptions,\n });\n}\n","import { arch as getArch, platform as getPlatform } from \"os\";\n\n/**\n * Returns the executable path for just located inside node_modules\n * The naming convention is just-${os}-${arch}\n * If the platform is `win32` or `cygwin`, executable will include a `.exe` extension\n * @see https://nodejs.org/api/os.html#osarch\n * @see https://nodejs.org/api/os.html#osplatform\n * @example \"x/xx/node_modules/just-darwin-arm64\"\n */\nexport async function getExePath() {\n const platform = getPlatform();\n const arch = getArch();\n\n let os = platform as string;\n let extension = \"\";\n\n if (platform === \"win32\" || platform === \"cygwin\") {\n os = \"windows\";\n extension = \".exe\";\n }\n\n try {\n // Since the bin will be located inside `node_modules`, we can simply call import.meta.resolve\n return import.meta.resolve(\n `rust-just-${os}-${arch}/bin/just${extension}`,\n );\n } catch (e) {\n throw new Error(\n `Couldn't find just binary inside node_modules for ${os}-${arch} (${e})`,\n );\n }\n}\n","import type { Options } from \"./options.js\";\n\n/**\n * Transforms a JavaScript object of options into an array\n * of strings that can be passed to {@link execa} for calling `just`\n *\n * @param options The options to transform\n * @returns The options as an array of strings\n */\nexport function optionsToStringArgs(options: Options): string[] {\n const args: string[] = [];\n\n for (const [key, value] of Object.entries(options)) {\n const hyphenCaseKey = key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\n if (\n (key === 'list' || key === 'shellCommand' || key === 'command') &&\n typeof value === 'string' &&\n value.trim().length > 0\n ) {\n const values = value.match(/'([^']+)'/g)?.map(v => v.replace(/'/g, '')) || [];\n if (values.length > 0) {\n args.push(`--${hyphenCaseKey}`, ...values);\n }\n } else if (key === 'set' && typeof value === 'string') {\n const values = value.match(/'([^']+)'/g)?.map(v => v.replace(/'/g, '')) || [];\n if (values.length === 2) {\n args.push(`--${hyphenCaseKey}`, values[0], values[1]);\n }\n } else if (key === 'verbose' && typeof value === 'number') {\n for (let i = 0; i < value; i++) {\n args.push(`--${hyphenCaseKey}`);\n }\n } else if (value === true) {\n args.push(`--${hyphenCaseKey}`);\n } else if (value === false || value === null) {\n continue;\n } else {\n args.push(`--${hyphenCaseKey}`, String(value));\n }\n }\n\n return args;\n}\n"]}
|