create-trokky 0.1.4 → 0.1.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/dist/cli.js CHANGED
@@ -86,6 +86,8 @@ async function main() {
86
86
  console.log(` # ${secret.name}= (${secret.optional ? 'optional — ' : ''}${secret.why})`);
87
87
  }
88
88
  }
89
+ if (config.target === 'workers')
90
+ console.log(' echo TROKKY_ENV=development >> .dev.vars');
89
91
  console.log(' npm install');
90
92
  console.log(config.target === 'workers' ? ' npm run build && npm run preview' : ' npm run dev');
91
93
  }
package/dist/emit.js CHANGED
@@ -56,7 +56,8 @@ export function packageJson(config) {
56
56
  else {
57
57
  scripts.dev = 'tsx watch src/server.ts';
58
58
  scripts.build = 'tsc -p tsconfig.json';
59
- scripts.start = 'node dist/server.js';
59
+ // rootDir is the project, so tsc mirrors src/ under dist/
60
+ scripts.start = 'node dist/src/server.js';
60
61
  }
61
62
  }
62
63
  return JSON.stringify({
@@ -457,7 +458,10 @@ export function envExample(config) {
457
458
  lines.push(...comment(secret.why), `${secret.name}=`, '');
458
459
  }
459
460
  if (edge) {
460
- lines.push(...comment('Local development only: keep this line in .dev.vars and never set it on the deployed'), ...comment('Worker, which must run with the production checks.'), 'TROKKY_ENV=development', '');
461
+ // TROKKY_ENV=development is not listed here: the deploy button offers every line of this
462
+ // file as a value to set on the deployed Worker, which must run with the production checks.
463
+ // The README adds it to the local .dev.vars instead.
464
+ lines.push(...comment('For local development, also add TROKKY_ENV=development to your .dev.vars (the'), ...comment('README shows how). Never set it on the deployed Worker.'), '');
461
465
  }
462
466
  if (config.data === 'postgres-data')
463
467
  lines.push('# Postgres connection string.', 'DATABASE_URL=', '');
package/dist/generate.js CHANGED
@@ -99,6 +99,7 @@ Generated with \`npm create trokky@latest\`.
99
99
 
100
100
  \`\`\`
101
101
  ${edge ? `cp .dev.vars.example .dev.vars # fill both secrets
102
+ echo TROKKY_ENV=development >> .dev.vars
102
103
  npm install
103
104
  npm run build && npm run preview` : `cp .env.example .env # fill both secrets
104
105
  npm install
@@ -109,16 +110,28 @@ ${edge ? `## Deploy
109
110
 
110
111
  \`\`\`
111
112
  npm run build && npm run deploy
113
+ npx wrangler secret put TROKKY_CLAIM_SECRET
114
+ npx wrangler secret put TROKKY_JWT_SECRET
112
115
  \`\`\`
113
116
 
117
+ \`.dev.vars\` is not uploaded, so the deployed Worker needs its own secrets; without
118
+ \`TROKKY_JWT_SECRET\` it answers with an error. Set the claim secret first: once the JWT secret
119
+ is in, the site answers, and an unset claim secret leaves the claim open.
120
+
114
121
  Wrangler provisions the D1 database and R2 bucket named in \`wrangler.jsonc\` on first deploy.
115
122
  \`database_id\` is intentionally empty: it is bound by name.
116
123
 
117
124
  ` : ''}## The first minute
118
125
 
119
- Open ${hasStudio(config) ? '`/studio`' : 'the API'}. Nobody owns this instance yet, so the first
120
- screen asks you to **claim** it: pick a username and password, and paste \`TROKKY_CLAIM_SECRET\`.
121
- ${config.content === 'blank' ? '' : 'Sample content appears a moment later — edit it or delete it.'}
126
+ ${hasStudio(config) ? `Open \`/studio\`. Nobody owns this instance yet, so the first screen asks you to **claim** it:
127
+ pick a username, an email and a password, and paste \`TROKKY_CLAIM_SECRET\`.` : `Nobody owns this instance yet. **Claim** it over HTTP (on a deployed site, use its URL instead of
128
+ localhost); the response signs you in:
129
+
130
+ \`\`\`
131
+ curl -X POST http://localhost:${edge ? '8787' : '3000'}/api/auth/claim -H 'Content-Type: application/json' \\
132
+ -d '{"username":"admin","email":"you@example.com","password":"<a strong password>","secret":"<TROKKY_CLAIM_SECRET>"}'
133
+ \`\`\``}
134
+ ${config.content === 'blank' ? '' : edge ? 'Sample content appears a moment after the claim — edit it or delete it.' : 'Sample content is written at the first start — edit it or delete it.'}
122
135
 
123
136
  Without a claim secret the claim is open to whoever reaches the URL first. That is fine for the
124
137
  minute between deploying and opening the link; it is not fine for an instance left sitting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-trokky",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Compose a Trokky project: pick the target, adapters and parts you want.",
5
5
  "type": "module",
6
6
  "license": "MIT",