scriptpal 1.4.1 โ 1.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.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.github/workflows/hypermod.yml +27 -0
- package/.github/workflows/release.yml +31 -0
- package/CHANGELOG.md +7 -0
- package/README.md +5 -9
- package/bin/detect-pkg-manager.js +10 -9
- package/bin/index.js +33 -33
- package/package.json +11 -3
- package/bin/main.js +0 -45
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
+
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
+
find the full documentation for it [in our repository](https://github.com/changesets/changesets).
|
|
6
|
+
|
|
7
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "restricted",
|
|
8
|
+
"baseBranch": "master",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Hypermod
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
deploymentId:
|
|
7
|
+
description: "The deployment ID containing instructions to apply on a repository"
|
|
8
|
+
deploymentKey:
|
|
9
|
+
description: "The deployment key to authenticate the request"
|
|
10
|
+
jobs:
|
|
11
|
+
receive_hypermod_event:
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
pull-requests: write
|
|
15
|
+
actions: read
|
|
16
|
+
checks: read
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v2
|
|
20
|
+
|
|
21
|
+
- name: Run Hypermod CLI
|
|
22
|
+
uses: hypermod-io/action@v1
|
|
23
|
+
with:
|
|
24
|
+
deploymentId: ${{ inputs.deploymentId }}
|
|
25
|
+
deploymentKey: ${{ inputs.deploymentKey }}
|
|
26
|
+
env:
|
|
27
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
pull-requests: write
|
|
6
|
+
id-token: write # Required for Trusted Publishing
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- master
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
release:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
env:
|
|
17
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 24.x
|
|
23
|
+
registry-url: "https://registry.npmjs.org"
|
|
24
|
+
- run: npm ci
|
|
25
|
+
- name: Create Release Pull Request or Publish
|
|
26
|
+
uses: changesets/action@v1
|
|
27
|
+
with:
|
|
28
|
+
publish: npm run release
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ npx scriptpal
|
|
|
42
42
|
- `--clipboard`, `-c` Copy command to clipboard
|
|
43
43
|
- `--help` Help me ๐
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
## `list`
|
|
46
46
|
|
|
47
47
|
`list` List all scripts found in local `package.json`.
|
|
48
48
|
|
|
@@ -50,18 +50,14 @@ It's possible to also run arbitrary scripts from your `package.json` by passing
|
|
|
50
50
|
|
|
51
51
|
For example: `scriptpal test` will run `npm run test`.
|
|
52
52
|
|
|
53
|
-
```bash
|
|
54
|
-
|
|
55
53
|
## Examples
|
|
56
54
|
|
|
57
|
-
- `$ scriptpal
|
|
58
|
-
- `$
|
|
59
|
-
- `$ scriptpal
|
|
60
|
-
- `$ scriptpal
|
|
61
|
-
- `$ scriptpal start`
|
|
55
|
+
- `$ scriptpal` => Shows a prompt containing a list of npm scripts from the closest `package.json`.
|
|
56
|
+
- `$ scriptpal --last` => Runs the previous command
|
|
57
|
+
- `$ scriptpal list` => Prints all npm scripts from the closest `package.json`.
|
|
58
|
+
- `$ scriptpal start` => Runs `npm run start`. Can be used with other scripts as well.
|
|
62
59
|
|
|
63
60
|
## You might also like...
|
|
64
61
|
|
|
65
62
|
- [CommitPal](https://github.com/zeropoly/commitpal): A delightful CLI tool for building complex commit messages
|
|
66
63
|
- [Enquirer](https://github.com/enquirer/enquirer): Stylish, intuitive and user-friendly prompts
|
|
67
|
-
```
|
|
@@ -8,18 +8,19 @@ function getPackageManager() {
|
|
|
8
8
|
{ id: "npm", file: hasFile("package-lock.json") },
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const foundPackageManagers = packageManagers.filter(
|
|
12
|
+
(manager) => typeof manager.file === "string",
|
|
13
|
+
);
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
packageManagers[i].file &&
|
|
16
|
-
packageManagers[i].file.split("/").length > largest
|
|
17
|
-
) {
|
|
18
|
-
largest = i;
|
|
19
|
-
}
|
|
15
|
+
if (!foundPackageManagers.length) {
|
|
16
|
+
return "npm";
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
const closestPackageManager = foundPackageManagers.sort(
|
|
20
|
+
(a, b) => b.file.split("/").length - a.file.split("/").length,
|
|
21
|
+
)[0];
|
|
22
|
+
|
|
23
|
+
return closestPackageManager.id;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
module.exports = { getPackageManager };
|
package/bin/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const { spawnSync } = require("child_process");
|
|
|
5
5
|
const clipboardy = require("clipboardy");
|
|
6
6
|
const Conf = require("conf");
|
|
7
7
|
const chalk = require("chalk");
|
|
8
|
-
const { Command
|
|
8
|
+
const { Command } = require("commander");
|
|
9
9
|
|
|
10
10
|
const { version } = require("../package.json");
|
|
11
11
|
const welcome = require("./welcome");
|
|
@@ -13,31 +13,32 @@ const { getPackageJson } = require("./file-manager");
|
|
|
13
13
|
const { promptShouldRerunPrevious, promptGetCommand } = require("./prompts");
|
|
14
14
|
const { getPackageManager } = require("./detect-pkg-manager");
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
packageJson = getPackageJson();
|
|
16
|
+
function getPackageScripts() {
|
|
17
|
+
const packageJson = getPackageJson();
|
|
20
18
|
|
|
21
19
|
if (!packageJson.scripts) {
|
|
22
20
|
throw new Error(chalk.red('No "scripts" found in package.json'));
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
process.exit(1);
|
|
22
|
+
|
|
23
|
+
return packageJson.scripts;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
function spawnScript(pkgManager, args) {
|
|
30
|
-
const
|
|
27
|
+
const result = spawnSync(pkgManager, args, { stdio: "inherit" });
|
|
28
|
+
|
|
29
|
+
if (result.error) {
|
|
30
|
+
throw result.error;
|
|
31
|
+
}
|
|
31
32
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
33
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
34
|
+
process.exit(result.status);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
async function main(flags) {
|
|
38
39
|
if (!flags.nowelcome) welcome();
|
|
39
40
|
|
|
40
|
-
const choices = Object.keys(
|
|
41
|
+
const choices = Object.keys(getPackageScripts());
|
|
41
42
|
const config = new Conf();
|
|
42
43
|
const previous = config.get(`${process.cwd()}.previous`);
|
|
43
44
|
|
|
@@ -57,7 +58,7 @@ async function main(flags) {
|
|
|
57
58
|
: await promptGetCommand(choices);
|
|
58
59
|
|
|
59
60
|
const pkgManager = getPackageManager();
|
|
60
|
-
let args =
|
|
61
|
+
let args = pkgManager === "npm" ? ["run", script] : [script];
|
|
61
62
|
args = parameters ? [...args, parameters] : args;
|
|
62
63
|
|
|
63
64
|
if (flags.clipboard) {
|
|
@@ -66,21 +67,30 @@ async function main(flags) {
|
|
|
66
67
|
return 0;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
spawnScript(pkgManager, args);
|
|
70
|
-
|
|
71
70
|
config.set(`${process.cwd()}.previous`, { script, parameters });
|
|
71
|
+
|
|
72
|
+
spawnScript(pkgManager, args);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
async function runLocalScript(script) {
|
|
76
|
+
const scripts = getPackageScripts();
|
|
77
|
+
|
|
78
|
+
if (!scripts[script]) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
chalk.red(`Script "${script}" not found in local package.json scripts.`),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
const pkgManager = getPackageManager();
|
|
76
|
-
const args =
|
|
85
|
+
const args = pkgManager === "npm" ? ["run", script] : [script];
|
|
77
86
|
|
|
78
87
|
spawnScript(pkgManager, args);
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
async function list() {
|
|
82
|
-
const
|
|
83
|
-
|
|
91
|
+
const scripts = getPackageScripts();
|
|
92
|
+
|
|
93
|
+
Object.entries(scripts).forEach(([key, value]) => {
|
|
84
94
|
console.log(`ยท ${chalk.greenBright(key)}: ${value}`);
|
|
85
95
|
});
|
|
86
96
|
}
|
|
@@ -104,28 +114,18 @@ Examples
|
|
|
104
114
|
$ scriptpal -lcn
|
|
105
115
|
$ scriptpal --nowelcome
|
|
106
116
|
$ npx scriptpal
|
|
107
|
-
$ scriptpal
|
|
117
|
+
$ scriptpal start`,
|
|
108
118
|
)
|
|
109
|
-
.
|
|
119
|
+
.argument("[script]")
|
|
120
|
+
.action(async (script, options) =>
|
|
121
|
+
script ? runLocalScript(script) : main(options),
|
|
122
|
+
);
|
|
110
123
|
|
|
111
124
|
program
|
|
112
125
|
.command("list")
|
|
113
126
|
.description("List available scripts from package.json")
|
|
114
127
|
.action(() => list());
|
|
115
128
|
|
|
116
|
-
// console.log(packageJson.scripts);
|
|
117
|
-
Object.keys(packageJson.scripts)
|
|
118
|
-
.filter((script) => !["list"].includes(script))
|
|
119
|
-
.forEach((script) => {
|
|
120
|
-
program
|
|
121
|
-
.usage("[global options] <file-paths>...")
|
|
122
|
-
.command(script)
|
|
123
|
-
.description(
|
|
124
|
-
`Runs local script "${script}" detected in local package.json`
|
|
125
|
-
)
|
|
126
|
-
.action(() => runLocalScript(script));
|
|
127
|
-
});
|
|
128
|
-
|
|
129
129
|
(async () => {
|
|
130
130
|
try {
|
|
131
131
|
await program.parseAsync(process.argv);
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scriptpal",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "A simple npm script palette for lazy people (like me)",
|
|
5
5
|
"main": "./bin/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"scriptpal": "
|
|
8
|
-
"spal": "
|
|
7
|
+
"scriptpal": "bin/index.js",
|
|
8
|
+
"spal": "bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node ./bin/index",
|
|
12
|
+
"changeset": "changeset",
|
|
13
|
+
"release": "changeset publish",
|
|
12
14
|
"test": "echo \"Error: no test specified\""
|
|
13
15
|
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
14
19
|
"author": "Daniel Del Core",
|
|
15
20
|
"repository": {
|
|
16
21
|
"type": "git",
|
|
@@ -35,5 +40,8 @@
|
|
|
35
40
|
"enquirer": "^2.3.2",
|
|
36
41
|
"find-config": "^1.0.0",
|
|
37
42
|
"gradient-string": "^1.2.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@changesets/cli": "^2.30.0"
|
|
38
46
|
}
|
|
39
47
|
}
|
package/bin/main.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const clipboardy = require("clipboardy");
|
|
3
|
-
const Conf = require("conf");
|
|
4
|
-
const welcome = require("./welcome");
|
|
5
|
-
const { promptShouldRerunPrevious, promptGetCommand } = require("./prompts");
|
|
6
|
-
const { getPackageManager } = require("./detect-pkg-manager");
|
|
7
|
-
const { packageJson } = require(".");
|
|
8
|
-
|
|
9
|
-
async function main(flags) {
|
|
10
|
-
if (!flags.nowelcome) welcome();
|
|
11
|
-
|
|
12
|
-
const choices = Object.keys(packageJson.scripts);
|
|
13
|
-
|
|
14
|
-
const config = new Conf();
|
|
15
|
-
const previous = config.get(`${process.cwd()}.previous`);
|
|
16
|
-
|
|
17
|
-
let shouldRerunPrevious = false;
|
|
18
|
-
|
|
19
|
-
if (!previous && flags.last) {
|
|
20
|
-
console.log("Previous command not found, continuing...\n");
|
|
21
|
-
} else if (previous && !flags.last) {
|
|
22
|
-
shouldRerunPrevious = await promptShouldRerunPrevious(previous);
|
|
23
|
-
} else {
|
|
24
|
-
shouldRerunPrevious = true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { script, parameters } =
|
|
28
|
-
(previous || flags.last) && shouldRerunPrevious
|
|
29
|
-
? previous
|
|
30
|
-
: await promptGetCommand(choices);
|
|
31
|
-
|
|
32
|
-
const pkgManager = getPackageManager();
|
|
33
|
-
let args = !pkgManager === "npm" ? ["run", script] : [script];
|
|
34
|
-
args = parameters ? [...args, parameters] : args;
|
|
35
|
-
|
|
36
|
-
if (flags.clipboard) {
|
|
37
|
-
await clipboardy.write(`${pkgManager} ${args.join(" ")}`);
|
|
38
|
-
console.log("Copied to clipboard ๐ ๐");
|
|
39
|
-
return 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// spawnScript(pkgManager, args);
|
|
43
|
-
config.set(`${process.cwd()}.previous`, { script, parameters });
|
|
44
|
-
}
|
|
45
|
-
exports.main = main;
|