@package-broker/cli 0.2.15
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 +29 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# PACKAGE.broker CLI
|
|
2
|
+
|
|
3
|
+
CLI tool to initialize PACKAGE.broker configuration in your project.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @package-broker/cli @package-broker/main
|
|
9
|
+
npx package-broker
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This command will:
|
|
13
|
+
- Copy `wrangler.toml` configuration template to your project
|
|
14
|
+
- Copy database migrations to `migrations/` directory
|
|
15
|
+
- Display next steps for setting up Cloudflare resources
|
|
16
|
+
|
|
17
|
+
## What's Next?
|
|
18
|
+
|
|
19
|
+
After running the init command, follow the displayed instructions to:
|
|
20
|
+
|
|
21
|
+
1. Configure your worker name and encryption key in `wrangler.toml`
|
|
22
|
+
2. Login to Cloudflare with `wrangler login`
|
|
23
|
+
3. Create required Cloudflare resources (D1, KV, R2)
|
|
24
|
+
4. Apply database migrations
|
|
25
|
+
5. Deploy your worker
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
For full documentation, visit: https://package.broker/docs/
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* PACKAGE.broker - CLI
|
|
4
|
+
* Copyright (C) 2025 Łukasz Bajsarowicz
|
|
5
|
+
* Licensed under AGPL-3.0
|
|
6
|
+
*/
|
|
7
|
+
import { copyFileSync, mkdirSync, readdirSync, existsSync } from 'fs';
|
|
8
|
+
import { join, dirname } from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
12
|
+
const COLORS = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bright: '\x1b[1m',
|
|
15
|
+
green: '\x1b[32m',
|
|
16
|
+
blue: '\x1b[34m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
red: '\x1b[31m',
|
|
19
|
+
};
|
|
20
|
+
function log(message, color = 'reset') {
|
|
21
|
+
console.log(`${COLORS[color]}${message}${COLORS.reset}`);
|
|
22
|
+
}
|
|
23
|
+
function main() {
|
|
24
|
+
const targetDir = process.cwd();
|
|
25
|
+
log('\nInitializing PACKAGE.broker...\n', 'bright');
|
|
26
|
+
// Find the main package in node_modules
|
|
27
|
+
const mainPackagePath = join(targetDir, 'node_modules', '@package-broker', 'main');
|
|
28
|
+
if (!existsSync(mainPackagePath)) {
|
|
29
|
+
log('Error: @package-broker/main not found in node_modules', 'red');
|
|
30
|
+
log(' Please run: npm install @package-broker/main', 'yellow');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
// Check if wrangler.toml already exists
|
|
34
|
+
const wranglerPath = join(targetDir, 'wrangler.toml');
|
|
35
|
+
if (existsSync(wranglerPath)) {
|
|
36
|
+
log('wrangler.toml already exists. Skipping.', 'yellow');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Copy wrangler.example.toml
|
|
40
|
+
const exampleTomlPath = join(mainPackagePath, 'wrangler.example.toml');
|
|
41
|
+
try {
|
|
42
|
+
copyFileSync(exampleTomlPath, wranglerPath);
|
|
43
|
+
log('Created wrangler.toml', 'green');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
log(`Error copying wrangler.toml: ${error.message}`, 'red');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Check if migrations directory exists
|
|
51
|
+
const migrationsDir = join(targetDir, 'migrations');
|
|
52
|
+
if (existsSync(migrationsDir)) {
|
|
53
|
+
log('migrations/ directory already exists. Skipping.', 'yellow');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Copy migrations
|
|
57
|
+
try {
|
|
58
|
+
mkdirSync(migrationsDir, { recursive: true });
|
|
59
|
+
const sourceMigrationsDir = join(mainPackagePath, 'migrations');
|
|
60
|
+
const migrationFiles = readdirSync(sourceMigrationsDir).filter((f) => f.endsWith('.sql'));
|
|
61
|
+
for (const file of migrationFiles) {
|
|
62
|
+
copyFileSync(join(sourceMigrationsDir, file), join(migrationsDir, file));
|
|
63
|
+
}
|
|
64
|
+
log(`Copied ${migrationFiles.length} migration files`, 'green');
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
log(`Error copying migrations: ${error.message}`, 'red');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
log('\nNext steps:', 'bright');
|
|
72
|
+
log('');
|
|
73
|
+
log('1. Edit wrangler.toml with your configuration', 'blue');
|
|
74
|
+
log(' - Set your worker name', 'blue');
|
|
75
|
+
log(' - Configure encryption key (generate with: openssl rand -base64 32)', 'blue');
|
|
76
|
+
log('');
|
|
77
|
+
log('2. Login to Cloudflare:', 'blue');
|
|
78
|
+
log(' npx wrangler login', 'blue');
|
|
79
|
+
log('');
|
|
80
|
+
log('3. Create Cloudflare resources:', 'blue');
|
|
81
|
+
log(' npx wrangler d1 create package-broker-db', 'blue');
|
|
82
|
+
log(' npx wrangler kv:namespace create PACKAGE_BROKER_KV', 'blue');
|
|
83
|
+
log(' npx wrangler r2 bucket create package-broker-artifacts', 'blue');
|
|
84
|
+
log('');
|
|
85
|
+
log('4. Update wrangler.toml with the generated IDs from step 3', 'blue');
|
|
86
|
+
log('');
|
|
87
|
+
log('5. Apply database migrations:', 'blue');
|
|
88
|
+
log(' npx wrangler d1 migrations apply package-broker-db --remote', 'blue');
|
|
89
|
+
log('');
|
|
90
|
+
log('6. Deploy to Cloudflare:', 'blue');
|
|
91
|
+
log(' npx wrangler deploy', 'blue');
|
|
92
|
+
log('');
|
|
93
|
+
log('Documentation: https://package.broker/docs/', 'bright');
|
|
94
|
+
log('');
|
|
95
|
+
}
|
|
96
|
+
main();
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,SAAS,GAAG,CAAC,OAAe,EAAE,QAA6B,OAAO;IAChE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,IAAI;IACX,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEhC,GAAG,CAAC,oCAAoC,EAAE,Q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,CAAC,2DAA2D,EAAE,MAAM,CAAC,CAAC;IACzE,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,4DAA4D,EAAE,MAAM,CAAC,CAAC;IAC1E,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;IAC7C,GAAG,CAAC,gEAAgE,EAAE,MAAM,CAAC,CAAC;IAC9E,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACxC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,6CAA6C,EAAE,QAAQ,CAAC,CAAC;IAC7D,GAAG,CAAC,EAAE,CAAC,CAAC;AACV,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@package-broker/cli",
|
|
3
|
+
"version": "0.2.15",
|
|
4
|
+
"description": "CLI tool to initialize PACKAGE.broker configuration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"package-broker": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"package.json",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "echo 'no linting configured'",
|
|
16
|
+
"build": "tsc -p tsconfig.build.json",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@package-broker/main": "*"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.11.0",
|
|
26
|
+
"typescript": "^5.3.3"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/package-broker/server",
|
|
31
|
+
"directory": "packages/cli"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|