@itd2902/auggw 1.0.1 → 1.0.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/bin/icbauggw.js +2 -0
- package/package.json +1 -1
- package/publish.js +63 -0
package/bin/icbauggw.js
ADDED
package/package.json
CHANGED
package/publish.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const CLI_DIR = path.join(__dirname);
|
|
7
|
+
const PKG_PATH = path.join(CLI_DIR, 'package.json');
|
|
8
|
+
const API_PATH = path.join(CLI_DIR, 'src', 'utils', 'api.js');
|
|
9
|
+
|
|
10
|
+
const packages = [
|
|
11
|
+
{
|
|
12
|
+
name: '@itd2902/auggw',
|
|
13
|
+
bin: { auggw: './bin/auggw.js' },
|
|
14
|
+
access: '--access public',
|
|
15
|
+
apiUrl: 'https://auggw.quangit.site',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'icbauggw',
|
|
19
|
+
bin: { icbauggw: './bin/icbauggw.js' },
|
|
20
|
+
access: '',
|
|
21
|
+
apiUrl: 'https://icbauggw.quangit.site',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const version = process.argv[2];
|
|
26
|
+
if (!version) {
|
|
27
|
+
console.error('Usage: node publish.js <version>');
|
|
28
|
+
console.error('Example: node publish.js 1.0.2');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const originalPkg = fs.readFileSync(PKG_PATH, 'utf8');
|
|
33
|
+
const originalApi = fs.readFileSync(API_PATH, 'utf8');
|
|
34
|
+
|
|
35
|
+
for (const pkg of packages) {
|
|
36
|
+
const json = JSON.parse(originalPkg);
|
|
37
|
+
json.name = pkg.name;
|
|
38
|
+
json.version = version;
|
|
39
|
+
json.bin = pkg.bin;
|
|
40
|
+
|
|
41
|
+
fs.writeFileSync(PKG_PATH, JSON.stringify(json, null, 2) + '\n');
|
|
42
|
+
|
|
43
|
+
// Swap DEFAULT_API_URL
|
|
44
|
+
const apiContent = originalApi.replace(
|
|
45
|
+
/const DEFAULT_API_URL = ".*?";/,
|
|
46
|
+
`const DEFAULT_API_URL = "${pkg.apiUrl}";`
|
|
47
|
+
);
|
|
48
|
+
fs.writeFileSync(API_PATH, apiContent);
|
|
49
|
+
|
|
50
|
+
console.log(`\nPublishing ${pkg.name}@${version} → ${pkg.apiUrl}`);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
execSync(`npm publish ${pkg.access}`.trim(), { cwd: CLI_DIR, stdio: 'inherit' });
|
|
54
|
+
console.log(`${pkg.name}@${version} published.`);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error(`Failed to publish ${pkg.name}:`, err.message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Restore originals
|
|
61
|
+
fs.writeFileSync(PKG_PATH, originalPkg);
|
|
62
|
+
fs.writeFileSync(API_PATH, originalApi);
|
|
63
|
+
console.log('\nFiles restored.');
|