cogsbox-sync 0.0.1

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/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "cogsbox-sync",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "bin": {
8
+ "create-cogsbox-worker": "./dist/bin/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "templates"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "dev": "tsup --watch",
17
+ "prepublishOnly": "node scripts/bundle.js && tsup"
18
+ },
19
+ "devDependencies": {
20
+ "@types/fs-extra": "^11.0.4",
21
+ "@types/prompts": "^2.4.9",
22
+ "@types/react": "^19.2.14",
23
+ "tsup": "^8.0.0",
24
+ "typescript": "^5.5.0"
25
+ },
26
+ "dependencies": {
27
+ "fs-extra": "^11.3.3",
28
+ "kleur": "^4.1.5",
29
+ "prompts": "^2.4.2",
30
+ "zod": "^4.3.6",
31
+ "zustand": "^5.0.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.0.0 || ^19.0.0"
35
+ }
36
+ }
@@ -0,0 +1,12 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = tab
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.yml]
12
+ indent_style = space
@@ -0,0 +1,6 @@
1
+ {
2
+ "printWidth": 140,
3
+ "singleQuote": true,
4
+ "semi": true,
5
+ "useTabs": true
6
+ }
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from 'child_process';
4
+ import { existsSync, readFileSync, writeFileSync, appendFileSync } from 'fs';
5
+ import crypto from 'crypto';
6
+
7
+ const jwtSecret = crypto.randomBytes(32).toString('hex');
8
+ const authSecret = crypto.randomBytes(32).toString('hex');
9
+
10
+ // Write .dev.vars for local development
11
+ const devVars = `JWT_SECRET=${jwtSecret}\nAUTH_SECRET=${authSecret}\n`;
12
+ writeFileSync('.dev.vars', devVars);
13
+ console.log('✅ Created .dev.vars for local development');
14
+
15
+ // Ensure .gitignore includes .dev.vars
16
+ if (existsSync('.gitignore')) {
17
+ const gitignore = readFileSync('.gitignore', 'utf-8');
18
+ if (!gitignore.includes('.dev.vars')) {
19
+ appendFileSync('.gitignore', '\n.dev.vars\n');
20
+ console.log('✅ Added .dev.vars to .gitignore');
21
+ }
22
+ } else {
23
+ writeFileSync('.gitignore', '.dev.vars\n');
24
+ console.log('✅ Created .gitignore with .dev.vars');
25
+ }
26
+
27
+ // Push secrets to Cloudflare
28
+ const shouldDeploy = process.argv.includes('--deploy');
29
+
30
+ try {
31
+ execSync(`echo "${jwtSecret}" | npx wrangler secret put JWT_SECRET`, { stdio: 'inherit' });
32
+ execSync(`echo "${authSecret}" | npx wrangler secret put AUTH_SECRET`, { stdio: 'inherit' });
33
+ console.log('✅ Secrets pushed to Cloudflare');
34
+ } catch (e) {
35
+ console.warn('⚠️ Could not push secrets to Cloudflare. Are you logged into wrangler?');
36
+ console.warn(' Run: npx wrangler login');
37
+ console.warn(' Then manually run:');
38
+ console.warn(` npx wrangler secret put JWT_SECRET`);
39
+ console.warn(` npx wrangler secret put AUTH_SECRET`);
40
+ }
41
+
42
+ if (shouldDeploy) {
43
+ try {
44
+ execSync('npx wrangler deploy', { stdio: 'inherit' });
45
+ console.log('✅ Deployed');
46
+ } catch (e) {
47
+ console.warn('⚠️ Deploy failed');
48
+ }
49
+ }
50
+
51
+ console.log('\n🔑 Your API key (AUTH_SECRET):');
52
+ console.log(` ${authSecret}`);
53
+ console.log('\n Save this — you will use it as your Bearer token.\n');