scriptpal 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/bin/index.js +36 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A simple npm script palette for lazy people who want a quick way to look through
|
|
|
8
8
|
|
|
9
9
|
- keyboard navigation
|
|
10
10
|
- autocompletion
|
|
11
|
-
-
|
|
11
|
+
- fuzzy finding
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<img width="580" src="assets/demo.gif" alt="Demo">
|
|
@@ -47,3 +47,8 @@ npx scriptpal
|
|
|
47
47
|
- `$ scriptpal --nowelcome`
|
|
48
48
|
- `$ npx scriptpal`
|
|
49
49
|
- `$ scriptpal --last --preset="emoji"`
|
|
50
|
+
|
|
51
|
+
## You might also like...
|
|
52
|
+
|
|
53
|
+
- [CommitPal](https://github.com/zeropoly/commitpal): A delightful CLI tool for building complex commit messages
|
|
54
|
+
- [Enquirer](https://github.com/enquirer/enquirer): Stylish, intuitive and user-friendly prompts
|
package/bin/index.js
CHANGED
|
@@ -11,41 +11,42 @@ const chalk = require("chalk");
|
|
|
11
11
|
const welcome = require("./welcome");
|
|
12
12
|
const { getPackageJson, hasFile } = require("./file-manager");
|
|
13
13
|
|
|
14
|
-
const promptShouldRerunPrevious = async previous => {
|
|
15
|
-
const previousCommand = `${previous.script} ${
|
|
16
|
-
""
|
|
14
|
+
const promptShouldRerunPrevious = async (previous) => {
|
|
15
|
+
const previousCommand = `${previous.script} ${
|
|
16
|
+
previous.parameters || ""
|
|
17
|
+
}`.trim();
|
|
17
18
|
|
|
18
19
|
return await new Confirm({
|
|
19
20
|
message: `Would you like to rerun the previous command?\n${chalk.greenBright(
|
|
20
21
|
previousCommand
|
|
21
|
-
)}
|
|
22
|
+
)}`,
|
|
22
23
|
}).run();
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const promptGetCommand = async choices => {
|
|
26
|
+
const promptGetCommand = async (choices) => {
|
|
26
27
|
const script = await new AutoComplete({
|
|
27
28
|
message: "Which script would you like to run? 🤷♂️",
|
|
28
29
|
limit: 18,
|
|
29
|
-
choices
|
|
30
|
+
choices,
|
|
30
31
|
}).run();
|
|
31
32
|
|
|
32
33
|
const {
|
|
33
|
-
values: { parameters }
|
|
34
|
+
values: { parameters },
|
|
34
35
|
} = await new Snippet({
|
|
35
36
|
message: "Would you like to add parameters?",
|
|
36
37
|
required: false,
|
|
37
38
|
fields: [
|
|
38
39
|
{
|
|
39
40
|
name: "parameters",
|
|
40
|
-
message: "parameters"
|
|
41
|
-
}
|
|
41
|
+
message: "parameters",
|
|
42
|
+
},
|
|
42
43
|
],
|
|
43
|
-
template: `${script} \${parameters}
|
|
44
|
+
template: `${script} \${parameters}`,
|
|
44
45
|
}).run();
|
|
45
46
|
|
|
46
47
|
return {
|
|
47
48
|
script,
|
|
48
|
-
parameters
|
|
49
|
+
parameters,
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
|
|
@@ -82,19 +83,16 @@ async function main(input, flags) {
|
|
|
82
83
|
if (flags.clipboard) {
|
|
83
84
|
await clipboardy.write(`${packageManager} ${args.join(" ")}`);
|
|
84
85
|
console.log("Copied to clipboard 👉 📋");
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const spawn = spawnSync(packageManager, args, { stdio: "inherit" });
|
|
90
|
+
|
|
91
|
+
if (spawn.error) {
|
|
92
|
+
throw new Error(spawn.error);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
config.set(`${process.cwd()}.previous`, {
|
|
95
|
-
script,
|
|
96
|
-
parameters
|
|
97
|
-
});
|
|
95
|
+
config.set(`${process.cwd()}.previous`, { script, parameters });
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
const cli = meow(
|
|
@@ -103,11 +101,11 @@ const cli = meow(
|
|
|
103
101
|
$ scriptpal
|
|
104
102
|
|
|
105
103
|
Options
|
|
106
|
-
--nowelcome, -n Omit welcome message
|
|
107
|
-
--help Help me
|
|
108
104
|
--last, -l Run previous command
|
|
109
|
-
--version, -v Version number
|
|
110
105
|
--clipboard, -c Copy command to clipboard
|
|
106
|
+
--nowelcome, -n Omit welcome message
|
|
107
|
+
--version Version number
|
|
108
|
+
--help Help me
|
|
111
109
|
|
|
112
110
|
Examples
|
|
113
111
|
$ scriptpal --nowelcome
|
|
@@ -118,18 +116,26 @@ const cli = meow(
|
|
|
118
116
|
flags: {
|
|
119
117
|
nowelcome: {
|
|
120
118
|
type: "boolean",
|
|
121
|
-
alias: "n"
|
|
119
|
+
alias: "n",
|
|
122
120
|
},
|
|
123
121
|
clipboard: {
|
|
124
122
|
type: "boolean",
|
|
125
|
-
alias: "c"
|
|
123
|
+
alias: "c",
|
|
126
124
|
},
|
|
127
125
|
last: {
|
|
128
126
|
type: "boolean",
|
|
129
|
-
alias: "l"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
127
|
+
alias: "l",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
132
130
|
}
|
|
133
131
|
);
|
|
134
132
|
|
|
135
|
-
|
|
133
|
+
(async () => {
|
|
134
|
+
try {
|
|
135
|
+
await main(cli.input[0], cli.flags);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(chalk.red(error));
|
|
138
|
+
console.log(error);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
})();
|