@bobfrankston/npmglobalize 1.0.12
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/.gitattributes +10 -0
- package/.globalize.jsonc +8 -0
- package/.vscode/settings.json +22 -0
- package/.vscode/spellright.dict +2 -0
- package/.vscode/tasks.json +20 -0
- package/cli.d.ts +6 -0
- package/cli.d.ts.map +1 -0
- package/cli.js +186 -0
- package/cli.js.map +1 -0
- package/cli.ts +197 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/index.js.map +1 -0
- package/index.ts +12 -0
- package/lib.d.ts +105 -0
- package/lib.d.ts.map +1 -0
- package/lib.js +867 -0
- package/lib.js.map +1 -0
- package/lib.ts +993 -0
- package/libnpmversion.d.ts +14 -0
- package/package.json +32 -0
- package/set-npm-token.ps1 +139 -0
- package/set-npm-token.sh +123 -0
- package/token.env +10 -0
- package/token.env.example +9 -0
- package/tsconfig.json +28 -0
package/.gitattributes
ADDED
package/.globalize.jsonc
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workbench.colorCustomizations": {
|
|
3
|
+
"activityBar.activeBackground": "#dcbee5",
|
|
4
|
+
"activityBar.background": "#dcbee5",
|
|
5
|
+
"activityBar.foreground": "#15202b",
|
|
6
|
+
"activityBar.inactiveForeground": "#15202b99",
|
|
7
|
+
"activityBarBadge.background": "#9f8940",
|
|
8
|
+
"activityBarBadge.foreground": "#15202b",
|
|
9
|
+
"commandCenter.border": "#15202b99",
|
|
10
|
+
"sash.hoverBorder": "#dcbee5",
|
|
11
|
+
"statusBar.background": "#c89ad6",
|
|
12
|
+
"statusBar.foreground": "#15202b",
|
|
13
|
+
"statusBarItem.hoverBackground": "#b476c7",
|
|
14
|
+
"statusBarItem.remoteBackground": "#c89ad6",
|
|
15
|
+
"statusBarItem.remoteForeground": "#15202b",
|
|
16
|
+
"titleBar.activeBackground": "#c89ad6",
|
|
17
|
+
"titleBar.activeForeground": "#15202b",
|
|
18
|
+
"titleBar.inactiveBackground": "#c89ad699",
|
|
19
|
+
"titleBar.inactiveForeground": "#15202b99"
|
|
20
|
+
},
|
|
21
|
+
"peacock.color": "#c89ad6"
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "tsc: watch",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "tsc",
|
|
8
|
+
"args": ["--watch"],
|
|
9
|
+
"runOptions": {
|
|
10
|
+
"runOn": "folderOpen"
|
|
11
|
+
},
|
|
12
|
+
"problemMatcher": "$tsc-watch",
|
|
13
|
+
"isBackground": true,
|
|
14
|
+
"group": {
|
|
15
|
+
"kind": "build",
|
|
16
|
+
"isDefault": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/cli.d.ts
ADDED
package/cli.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";AACA;;GAEG;AA6JH,wBAAuB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAgC3C"}
|
package/cli.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmglobalize CLI - Transform file: dependencies to npm versions for publishing
|
|
4
|
+
*/
|
|
5
|
+
import { globalize, readConfig } from './lib.js';
|
|
6
|
+
function printHelp() {
|
|
7
|
+
console.log(`
|
|
8
|
+
npmglobalize - Transform file: dependencies to npm versions for publishing
|
|
9
|
+
|
|
10
|
+
Usage: npmglobalize [options]
|
|
11
|
+
|
|
12
|
+
Release Options:
|
|
13
|
+
--patch Bump patch version (default)
|
|
14
|
+
--minor Bump minor version
|
|
15
|
+
--major Bump major version
|
|
16
|
+
--apply Just transform, don't publish
|
|
17
|
+
--cleanup Restore from .dependencies
|
|
18
|
+
|
|
19
|
+
Install Options:
|
|
20
|
+
--install Global install after publish (Windows)
|
|
21
|
+
--wsl Also install globally in WSL
|
|
22
|
+
|
|
23
|
+
Mode Options:
|
|
24
|
+
--files Keep file: paths after publish (default)
|
|
25
|
+
--nofiles Keep npm versions permanently
|
|
26
|
+
|
|
27
|
+
Git/npm Visibility:
|
|
28
|
+
--git private Make git repo private (default)
|
|
29
|
+
--git public Make git repo public (requires confirmation)
|
|
30
|
+
--npm private Mark npm package private (skip publish)
|
|
31
|
+
--npm public Publish to npm (default)
|
|
32
|
+
|
|
33
|
+
Other Options:
|
|
34
|
+
--init Initialize git/npm if needed
|
|
35
|
+
--force Continue despite git errors
|
|
36
|
+
--dry-run Show what would happen
|
|
37
|
+
--quiet Suppress npm warnings (default)
|
|
38
|
+
--verbose Show detailed output
|
|
39
|
+
--help, -h Show this help
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
npmglobalize Transform + release (patch)
|
|
43
|
+
npmglobalize --minor Release with minor version bump
|
|
44
|
+
npmglobalize --install --wsl Release + install on Windows and WSL
|
|
45
|
+
npmglobalize --apply Just transform, no publish
|
|
46
|
+
npmglobalize --cleanup Restore original dependencies
|
|
47
|
+
npmglobalize --init Initialize new git repo + release
|
|
48
|
+
npmglobalize --dry-run Preview what would happen
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
function parseArgs(args) {
|
|
52
|
+
const options = {
|
|
53
|
+
help: false,
|
|
54
|
+
error: ''
|
|
55
|
+
};
|
|
56
|
+
const unrecognized = [];
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
const arg = args[i];
|
|
59
|
+
switch (arg) {
|
|
60
|
+
case '--help':
|
|
61
|
+
case '-h':
|
|
62
|
+
options.help = true;
|
|
63
|
+
break;
|
|
64
|
+
case '--patch':
|
|
65
|
+
options.bump = 'patch';
|
|
66
|
+
break;
|
|
67
|
+
case '--minor':
|
|
68
|
+
options.bump = 'minor';
|
|
69
|
+
break;
|
|
70
|
+
case '--major':
|
|
71
|
+
options.bump = 'major';
|
|
72
|
+
break;
|
|
73
|
+
case '--apply':
|
|
74
|
+
options.applyOnly = true;
|
|
75
|
+
break;
|
|
76
|
+
case '--cleanup':
|
|
77
|
+
options.cleanup = true;
|
|
78
|
+
break;
|
|
79
|
+
case '--install':
|
|
80
|
+
case '-i':
|
|
81
|
+
options.install = true;
|
|
82
|
+
break;
|
|
83
|
+
case '--noinstall':
|
|
84
|
+
case '-ni':
|
|
85
|
+
options.install = false;
|
|
86
|
+
break;
|
|
87
|
+
case '--wsl':
|
|
88
|
+
options.wsl = true;
|
|
89
|
+
break;
|
|
90
|
+
case '--nowsl':
|
|
91
|
+
options.wsl = false;
|
|
92
|
+
break;
|
|
93
|
+
case '--force':
|
|
94
|
+
options.force = true;
|
|
95
|
+
break;
|
|
96
|
+
case '--files':
|
|
97
|
+
options.files = true;
|
|
98
|
+
break;
|
|
99
|
+
case '--nofiles':
|
|
100
|
+
options.files = false;
|
|
101
|
+
break;
|
|
102
|
+
case '--dry-run':
|
|
103
|
+
options.dryRun = true;
|
|
104
|
+
break;
|
|
105
|
+
case '--quiet':
|
|
106
|
+
options.quiet = true;
|
|
107
|
+
break;
|
|
108
|
+
case '--verbose':
|
|
109
|
+
options.verbose = true;
|
|
110
|
+
options.quiet = false;
|
|
111
|
+
break;
|
|
112
|
+
case '--init':
|
|
113
|
+
options.init = true;
|
|
114
|
+
break;
|
|
115
|
+
case '--git':
|
|
116
|
+
i++;
|
|
117
|
+
if (args[i] === 'private' || args[i] === 'public') {
|
|
118
|
+
options.gitVisibility = args[i];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
options.error = `--git requires 'private' or 'public', got: ${args[i]}`;
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case '--npm':
|
|
125
|
+
i++;
|
|
126
|
+
if (args[i] === 'private' || args[i] === 'public') {
|
|
127
|
+
options.npmVisibility = args[i];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
options.error = `--npm requires 'private' or 'public', got: ${args[i]}`;
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case '--message':
|
|
134
|
+
case '-m':
|
|
135
|
+
i++;
|
|
136
|
+
if (args[i]) {
|
|
137
|
+
options.message = args[i];
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
options.error = '-m/--message requires a commit message';
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
if (arg.startsWith('-')) {
|
|
145
|
+
unrecognized.push(arg);
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (unrecognized.length > 0) {
|
|
151
|
+
options.error = `Unrecognized arguments: ${unrecognized.join(', ')}`;
|
|
152
|
+
}
|
|
153
|
+
return options;
|
|
154
|
+
}
|
|
155
|
+
export async function main() {
|
|
156
|
+
const args = process.argv.slice(2);
|
|
157
|
+
const cliOptions = parseArgs(args);
|
|
158
|
+
if (cliOptions.help) {
|
|
159
|
+
printHelp();
|
|
160
|
+
process.exit(0);
|
|
161
|
+
}
|
|
162
|
+
if (cliOptions.error) {
|
|
163
|
+
console.error(`Error: ${cliOptions.error}`);
|
|
164
|
+
console.error('Run with --help for usage.');
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
const cwd = process.cwd();
|
|
168
|
+
// Load config file and merge with CLI options (CLI takes precedence)
|
|
169
|
+
const configOptions = readConfig(cwd);
|
|
170
|
+
const options = { ...configOptions, ...cliOptions };
|
|
171
|
+
try {
|
|
172
|
+
const success = await globalize(cwd, options);
|
|
173
|
+
process.exit(success ? 0 : 1);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error(`Error: ${error.message}`);
|
|
177
|
+
if (options.verbose) {
|
|
178
|
+
console.error(error.stack);
|
|
179
|
+
}
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (import.meta.main) {
|
|
184
|
+
main();
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=cli.js.map
|
package/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAoB,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnE,SAAS,SAAS;IACd,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Cf,CAAC,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAc;IAC7B,MAAM,OAAO,GAAwD;QACjE,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,EAAE;KACZ,CAAC;IAEF,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpB,QAAQ,GAAG,EAAE,CAAC;YACV,KAAK,QAAQ,CAAC;YACd,KAAK,IAAI;gBACL,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;gBACpB,MAAM;YACV,KAAK,SAAS;gBACV,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;gBACvB,MAAM;YACV,KAAK,SAAS;gBACV,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;gBACvB,MAAM;YACV,KAAK,SAAS;gBACV,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;gBACvB,MAAM;YACV,KAAK,SAAS;gBACV,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;gBACzB,MAAM;YACV,KAAK,WAAW;gBACZ,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC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CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,UAAU,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,qEAAqE;IACrE,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;IAEpD,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAU,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC;AACX,CAAC"}
|
package/cli.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmglobalize CLI - Transform file: dependencies to npm versions for publishing
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { globalize, GlobalizeOptions, readConfig } from './lib.js';
|
|
7
|
+
|
|
8
|
+
function printHelp(): void {
|
|
9
|
+
console.log(`
|
|
10
|
+
npmglobalize - Transform file: dependencies to npm versions for publishing
|
|
11
|
+
|
|
12
|
+
Usage: npmglobalize [options]
|
|
13
|
+
|
|
14
|
+
Release Options:
|
|
15
|
+
--patch Bump patch version (default)
|
|
16
|
+
--minor Bump minor version
|
|
17
|
+
--major Bump major version
|
|
18
|
+
--apply Just transform, don't publish
|
|
19
|
+
--cleanup Restore from .dependencies
|
|
20
|
+
|
|
21
|
+
Install Options:
|
|
22
|
+
--install Global install after publish (Windows)
|
|
23
|
+
--wsl Also install globally in WSL
|
|
24
|
+
|
|
25
|
+
Mode Options:
|
|
26
|
+
--files Keep file: paths after publish (default)
|
|
27
|
+
--nofiles Keep npm versions permanently
|
|
28
|
+
|
|
29
|
+
Git/npm Visibility:
|
|
30
|
+
--git private Make git repo private (default)
|
|
31
|
+
--git public Make git repo public (requires confirmation)
|
|
32
|
+
--npm private Mark npm package private (skip publish)
|
|
33
|
+
--npm public Publish to npm (default)
|
|
34
|
+
|
|
35
|
+
Other Options:
|
|
36
|
+
--init Initialize git/npm if needed
|
|
37
|
+
--force Continue despite git errors
|
|
38
|
+
--dry-run Show what would happen
|
|
39
|
+
--quiet Suppress npm warnings (default)
|
|
40
|
+
--verbose Show detailed output
|
|
41
|
+
--help, -h Show this help
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
npmglobalize Transform + release (patch)
|
|
45
|
+
npmglobalize --minor Release with minor version bump
|
|
46
|
+
npmglobalize --install --wsl Release + install on Windows and WSL
|
|
47
|
+
npmglobalize --apply Just transform, no publish
|
|
48
|
+
npmglobalize --cleanup Restore original dependencies
|
|
49
|
+
npmglobalize --init Initialize new git repo + release
|
|
50
|
+
npmglobalize --dry-run Preview what would happen
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function parseArgs(args: string[]): GlobalizeOptions & { help: boolean; error: string } {
|
|
55
|
+
const options: GlobalizeOptions & { help: boolean; error: string } = {
|
|
56
|
+
help: false,
|
|
57
|
+
error: ''
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const unrecognized: string[] = [];
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < args.length; i++) {
|
|
63
|
+
const arg = args[i];
|
|
64
|
+
|
|
65
|
+
switch (arg) {
|
|
66
|
+
case '--help':
|
|
67
|
+
case '-h':
|
|
68
|
+
options.help = true;
|
|
69
|
+
break;
|
|
70
|
+
case '--patch':
|
|
71
|
+
options.bump = 'patch';
|
|
72
|
+
break;
|
|
73
|
+
case '--minor':
|
|
74
|
+
options.bump = 'minor';
|
|
75
|
+
break;
|
|
76
|
+
case '--major':
|
|
77
|
+
options.bump = 'major';
|
|
78
|
+
break;
|
|
79
|
+
case '--apply':
|
|
80
|
+
options.applyOnly = true;
|
|
81
|
+
break;
|
|
82
|
+
case '--cleanup':
|
|
83
|
+
options.cleanup = true;
|
|
84
|
+
break;
|
|
85
|
+
case '--install':
|
|
86
|
+
case '-i':
|
|
87
|
+
options.install = true;
|
|
88
|
+
break;
|
|
89
|
+
case '--noinstall':
|
|
90
|
+
case '-ni':
|
|
91
|
+
options.install = false;
|
|
92
|
+
break;
|
|
93
|
+
case '--wsl':
|
|
94
|
+
options.wsl = true;
|
|
95
|
+
break;
|
|
96
|
+
case '--nowsl':
|
|
97
|
+
options.wsl = false;
|
|
98
|
+
break;
|
|
99
|
+
case '--force':
|
|
100
|
+
options.force = true;
|
|
101
|
+
break;
|
|
102
|
+
case '--files':
|
|
103
|
+
options.files = true;
|
|
104
|
+
break;
|
|
105
|
+
case '--nofiles':
|
|
106
|
+
options.files = false;
|
|
107
|
+
break;
|
|
108
|
+
case '--dry-run':
|
|
109
|
+
options.dryRun = true;
|
|
110
|
+
break;
|
|
111
|
+
case '--quiet':
|
|
112
|
+
options.quiet = true;
|
|
113
|
+
break;
|
|
114
|
+
case '--verbose':
|
|
115
|
+
options.verbose = true;
|
|
116
|
+
options.quiet = false;
|
|
117
|
+
break;
|
|
118
|
+
case '--init':
|
|
119
|
+
options.init = true;
|
|
120
|
+
break;
|
|
121
|
+
case '--git':
|
|
122
|
+
i++;
|
|
123
|
+
if (args[i] === 'private' || args[i] === 'public') {
|
|
124
|
+
options.gitVisibility = args[i] as 'private' | 'public';
|
|
125
|
+
} else {
|
|
126
|
+
options.error = `--git requires 'private' or 'public', got: ${args[i]}`;
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case '--npm':
|
|
130
|
+
i++;
|
|
131
|
+
if (args[i] === 'private' || args[i] === 'public') {
|
|
132
|
+
options.npmVisibility = args[i] as 'private' | 'public';
|
|
133
|
+
} else {
|
|
134
|
+
options.error = `--npm requires 'private' or 'public', got: ${args[i]}`;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case '--message':
|
|
138
|
+
case '-m':
|
|
139
|
+
i++;
|
|
140
|
+
if (args[i]) {
|
|
141
|
+
options.message = args[i];
|
|
142
|
+
} else {
|
|
143
|
+
options.error = '-m/--message requires a commit message';
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
if (arg.startsWith('-')) {
|
|
148
|
+
unrecognized.push(arg);
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (unrecognized.length > 0) {
|
|
155
|
+
options.error = `Unrecognized arguments: ${unrecognized.join(', ')}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return options;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export async function main(): Promise<void> {
|
|
162
|
+
const args = process.argv.slice(2);
|
|
163
|
+
const cliOptions = parseArgs(args);
|
|
164
|
+
|
|
165
|
+
if (cliOptions.help) {
|
|
166
|
+
printHelp();
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (cliOptions.error) {
|
|
171
|
+
console.error(`Error: ${cliOptions.error}`);
|
|
172
|
+
console.error('Run with --help for usage.');
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const cwd = process.cwd();
|
|
177
|
+
|
|
178
|
+
// Load config file and merge with CLI options (CLI takes precedence)
|
|
179
|
+
const configOptions = readConfig(cwd);
|
|
180
|
+
const options = { ...configOptions, ...cliOptions };
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const success = await globalize(cwd, options);
|
|
184
|
+
process.exit(success ? 0 : 1);
|
|
185
|
+
}
|
|
186
|
+
catch (error: any) {
|
|
187
|
+
console.error(`Error: ${error.message}`);
|
|
188
|
+
if (options.verbose) {
|
|
189
|
+
console.error(error.stack);
|
|
190
|
+
}
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (import.meta.main) {
|
|
196
|
+
main();
|
|
197
|
+
}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,UAAU,CAAC"}
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,UAAU,CAAC;AAClB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC;AACX,CAAC"}
|
package/index.ts
ADDED
package/lib.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npmglobalize - Transform file: dependencies to npm versions for publishing
|
|
3
|
+
*/
|
|
4
|
+
/** Options for the globalize operation */
|
|
5
|
+
export interface GlobalizeOptions {
|
|
6
|
+
/** Bump type: patch (default), minor, major */
|
|
7
|
+
bump?: 'patch' | 'minor' | 'major';
|
|
8
|
+
/** Just transform, don't publish */
|
|
9
|
+
applyOnly?: boolean;
|
|
10
|
+
/** Restore from .dependencies */
|
|
11
|
+
cleanup?: boolean;
|
|
12
|
+
/** Global install after publish */
|
|
13
|
+
install?: boolean;
|
|
14
|
+
/** Also install in WSL */
|
|
15
|
+
wsl?: boolean;
|
|
16
|
+
/** Continue despite git errors */
|
|
17
|
+
force?: boolean;
|
|
18
|
+
/** Keep file: paths after publish (default true) */
|
|
19
|
+
files?: boolean;
|
|
20
|
+
/** Show what would happen */
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
/** Suppress npm warnings (default true) */
|
|
23
|
+
quiet?: boolean;
|
|
24
|
+
/** Show verbose output */
|
|
25
|
+
verbose?: boolean;
|
|
26
|
+
/** Initialize git/npm if needed */
|
|
27
|
+
init?: boolean;
|
|
28
|
+
/** Git visibility: private (default) or public */
|
|
29
|
+
gitVisibility?: 'private' | 'public';
|
|
30
|
+
/** npm visibility: public (default) or private */
|
|
31
|
+
npmVisibility?: 'private' | 'public';
|
|
32
|
+
/** Custom commit message */
|
|
33
|
+
message?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Read and parse package.json from a directory */
|
|
36
|
+
export declare function readPackageJson(dir: string): any;
|
|
37
|
+
/** Read .globalize.jsonc config file */
|
|
38
|
+
export declare function readConfig(dir: string): Partial<GlobalizeOptions>;
|
|
39
|
+
/** Write .globalize.jsonc config file */
|
|
40
|
+
export declare function writeConfig(dir: string, config: Partial<GlobalizeOptions>): void;
|
|
41
|
+
/** Write package.json to a directory */
|
|
42
|
+
export declare function writePackageJson(dir: string, pkg: any): void;
|
|
43
|
+
/** Resolve a file: path to absolute path */
|
|
44
|
+
export declare function resolveFilePath(fileRef: string, baseDir: string): string;
|
|
45
|
+
/** Check if a dependency value is a file: reference */
|
|
46
|
+
export declare function isFileRef(value: string): boolean;
|
|
47
|
+
/** Get all file: dependencies from package.json */
|
|
48
|
+
export declare function getFileRefs(pkg: any): Map<string, {
|
|
49
|
+
key: string;
|
|
50
|
+
name: string;
|
|
51
|
+
value: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Transform file: dependencies to npm versions */
|
|
54
|
+
export declare function transformDeps(pkg: any, baseDir: string, verbose?: boolean): boolean;
|
|
55
|
+
/** Restore file: dependencies from .dependencies */
|
|
56
|
+
export declare function restoreDeps(pkg: any, verbose?: boolean): boolean;
|
|
57
|
+
/** Check if .dependencies exist (already transformed) */
|
|
58
|
+
export declare function hasBackup(pkg: any): boolean;
|
|
59
|
+
/** Run a command and return success status */
|
|
60
|
+
export declare function runCommand(cmd: string, args: string[], options?: {
|
|
61
|
+
silent?: boolean;
|
|
62
|
+
cwd?: string;
|
|
63
|
+
}): {
|
|
64
|
+
success: boolean;
|
|
65
|
+
output: string;
|
|
66
|
+
stderr: string;
|
|
67
|
+
};
|
|
68
|
+
/** Run a command and throw on failure */
|
|
69
|
+
export declare function runCommandOrThrow(cmd: string, args: string[], options?: {
|
|
70
|
+
silent?: boolean;
|
|
71
|
+
cwd?: string;
|
|
72
|
+
}): string;
|
|
73
|
+
/** Git status checks */
|
|
74
|
+
export interface GitStatus {
|
|
75
|
+
isRepo: boolean;
|
|
76
|
+
hasRemote: boolean;
|
|
77
|
+
hasUncommitted: boolean;
|
|
78
|
+
hasUnpushed: boolean;
|
|
79
|
+
hasMergeConflict: boolean;
|
|
80
|
+
isDetachedHead: boolean;
|
|
81
|
+
currentBranch: string;
|
|
82
|
+
remoteBranch: string;
|
|
83
|
+
}
|
|
84
|
+
export declare function getGitStatus(cwd: string): GitStatus;
|
|
85
|
+
/** Validate package.json for release */
|
|
86
|
+
export declare function validatePackageJson(pkg: any): string[];
|
|
87
|
+
/** Prompt user for confirmation */
|
|
88
|
+
export declare function confirm(message: string, defaultYes?: boolean): Promise<boolean>;
|
|
89
|
+
/** Initialize git repository */
|
|
90
|
+
export declare function initGit(cwd: string, visibility: 'private' | 'public', dryRun: boolean): Promise<boolean>;
|
|
91
|
+
/** Main globalize function */
|
|
92
|
+
export declare function globalize(cwd: string, options?: GlobalizeOptions): Promise<boolean>;
|
|
93
|
+
declare const _default: {
|
|
94
|
+
globalize: typeof globalize;
|
|
95
|
+
transformDeps: typeof transformDeps;
|
|
96
|
+
restoreDeps: typeof restoreDeps;
|
|
97
|
+
readPackageJson: typeof readPackageJson;
|
|
98
|
+
writePackageJson: typeof writePackageJson;
|
|
99
|
+
getGitStatus: typeof getGitStatus;
|
|
100
|
+
validatePackageJson: typeof validatePackageJson;
|
|
101
|
+
confirm: typeof confirm;
|
|
102
|
+
initGit: typeof initGit;
|
|
103
|
+
};
|
|
104
|
+
export default _default;
|
|
105
|
+
//# sourceMappingURL=lib.d.ts.map
|
package/lib.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["lib.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC7B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IACnC,oCAAoC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,IAAI,CAAC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