@gkucmierz/dport 1.0.0 → 1.1.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/.github/workflows/npm-publish.yml +4 -7
- package/bin/dport.js +22 -8
- package/package.json +1 -2
|
@@ -24,13 +24,10 @@ jobs:
|
|
|
24
24
|
env:
|
|
25
25
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
26
26
|
|
|
27
|
-
- name: Setup Gitea Registry
|
|
28
|
-
uses: actions/setup-node@v4
|
|
29
|
-
with:
|
|
30
|
-
node-version: '20.x'
|
|
31
|
-
registry-url: 'https://gitea.7u.pl/api/packages/gkucmierz/npm/'
|
|
32
|
-
|
|
33
27
|
- name: Publish to Gitea Registry
|
|
34
|
-
run:
|
|
28
|
+
run: |
|
|
29
|
+
npm config set registry 'https://gitea.7u.pl/api/packages/gkucmierz/npm/'
|
|
30
|
+
npm config set '//gitea.7u.pl/api/packages/gkucmierz/npm/:_authToken' '${{ secrets.LOCAL_PACKAGE_REGISTRY }}'
|
|
31
|
+
npm publish
|
|
35
32
|
env:
|
|
36
33
|
NODE_AUTH_TOKEN: ${{ secrets.LOCAL_PACKAGE_REGISTRY }}
|
package/bin/dport.js
CHANGED
|
@@ -5,15 +5,16 @@ import path from 'path';
|
|
|
5
5
|
import { getDeterministicPort } from '../index.js';
|
|
6
6
|
|
|
7
7
|
const args = process.argv.slice(2);
|
|
8
|
-
const command = args.find(a => !a.startsWith('-')) || 'calc';
|
|
9
8
|
const hasFixFlag = args.includes('--fix');
|
|
10
9
|
|
|
11
|
-
if (
|
|
10
|
+
if (args.length === 0 || args.includes('help') || args.includes('--help')) {
|
|
12
11
|
console.log(`
|
|
13
|
-
Usage: dport
|
|
12
|
+
Usage: dport [name] [options]
|
|
13
|
+
dport <command> [options]
|
|
14
14
|
|
|
15
15
|
Commands:
|
|
16
|
-
|
|
16
|
+
[name] Calculate deterministic port for an arbitrary string (e.g. dport "zulip").
|
|
17
|
+
calc [name] Calculate deterministic port for current package.json or [name].
|
|
17
18
|
fix [name] Alias for 'calc --fix'.
|
|
18
19
|
|
|
19
20
|
Options:
|
|
@@ -23,8 +24,19 @@ Options:
|
|
|
23
24
|
process.exit(0);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
let firstArg = args.find(a => !a.startsWith('-'));
|
|
28
|
+
let command = 'calc';
|
|
29
|
+
let name = null;
|
|
30
|
+
|
|
31
|
+
if (firstArg === 'calc' || firstArg === 'show' || firstArg === 'fix') {
|
|
32
|
+
command = firstArg;
|
|
33
|
+
name = args.find(a => !a.startsWith('-') && a !== command);
|
|
34
|
+
} else if (firstArg) {
|
|
35
|
+
command = 'calc';
|
|
36
|
+
name = firstArg; // Treat arbitrary string as name
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
if (command === 'calc' || command === 'show' || command === 'fix') {
|
|
27
|
-
let name = args.find(a => !a.startsWith('-') && a !== command);
|
|
28
40
|
let pkgPath, pkg;
|
|
29
41
|
|
|
30
42
|
if (!name || hasFixFlag || command === 'fix') {
|
|
@@ -34,8 +46,10 @@ if (command === 'calc' || command === 'show' || command === 'fix') {
|
|
|
34
46
|
pkg = JSON.parse(pkgContext);
|
|
35
47
|
if (!name) name = pkg.name;
|
|
36
48
|
} catch(e) {
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
if (!name) {
|
|
50
|
+
console.error('Error: Could not read package.json in current directory and no name provided.');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
39
53
|
}
|
|
40
54
|
}
|
|
41
55
|
|
|
@@ -75,5 +89,5 @@ if (command === 'calc' || command === 'show' || command === 'fix') {
|
|
|
75
89
|
process.exit(0);
|
|
76
90
|
}
|
|
77
91
|
|
|
78
|
-
console.error(`Unknown command:
|
|
92
|
+
console.error(`Unknown command: ${command}`);
|
|
79
93
|
process.exit(1);
|
package/package.json
CHANGED