@decohere/create 0.0.1-dev.20261105.99 → 0.0.1-dev.20261106.139

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 CHANGED
@@ -6,11 +6,13 @@ Docker is required on the host. `@decohere/create` only pulls `ghcr.io/typesmith
6
6
 
7
7
  ## Usage
8
8
 
9
- `npm create` already says “create”, so the first token is the kind (`webapi`), not `create` again. The launcher forwards `decohere create webapi …` into the builder image.
9
+ `npm create` already says “create”, so the first token is the kind (`webapi`), not `create` again. `webapi` is the only kind today, so you can leave it out and give just the project's folder. The launcher forwards `decohere create webapi …` into the builder image.
10
10
 
11
- This run prompts for database, auth, Postman, and whether to install:
11
+ This run prompts for database and auth:
12
12
 
13
13
  ```bash
14
+ npm create @decohere@dev my-app
15
+ # or
14
16
  npm create @decohere@dev webapi -d my-app
15
17
  # or
16
18
  npx @decohere/create@dev webapi -d my-app
@@ -21,14 +23,14 @@ decohere create webapi -d my-app
21
23
  To skip prompts, pass every answer up front (`-y` means “install deps, don’t ask”):
22
24
 
23
25
  ```bash
24
- npm create @decohere@dev -- webapi -d my-app --database postgres/typeorm --auth none --postman local -y
26
+ npm create @decohere@dev -- webapi -d my-app --database postgres/typeorm --auth none -y
25
27
  ```
26
28
 
27
29
  Target directory is `webapi`'s optional argument or `-d` (default `.`). `npm create` treats `-d` as its own loglevel flag and forwards `my-app` as a positional — that form is supported. Extra create flags still need `--` after `npm create`.
28
30
 
29
- The first token after the package must be a command (`webapi`); a bare directory name is an unknown command.
31
+ A first token that isn't a command (`webapi`, `create`, `add`, `auth0`, `help`) or a flag is the project's folder, so a mistyped command starts a project with that name.
30
32
 
31
- The scaffolded Dev Container asks **y/N** (TTY only) before npm auth and optional codebase RAG MCP (semantic search). Decline or run without a TTY to skip. Credentials are written under the project `.cursor/` directory (gitignored).
33
+ The scaffolded Dev Container asks no questions. `gh` is installed in it: run `gh auth login` yourself if you want it, and the login persists in `.devcontainer/gh-auth/` (gitignored).
32
34
 
33
35
  ## Commands
34
36
 
@@ -109,7 +111,7 @@ The Auth0 CLI lives in the create image. Host tokens are stored in `~/.config/au
109
111
  # Device/URL login — open the printed URL in your browser
110
112
  npx @decohere/create auth0 login
111
113
 
112
- # Update the Auth0 API + Postman SPA for this workspace (run from the project, or pass -d)
114
+ # Update the Auth0 API and login app for this workspace (run from the project, or pass -d)
113
115
  npx @decohere/create auth0 configure
114
116
  npx @decohere/create auth0 configure -d my-app
115
117
 
@@ -118,7 +120,15 @@ decohere auth0 login
118
120
  decohere auth0 configure
119
121
  ```
120
122
 
121
- `configure` does **not** rewrite application source. It scans `projects/*/src` for `@Authorize("action", "Subject")`, adds those permissions to the Auth0 API (keeping any already on the API), assigns them to `AUTH0_ADMIN_USER_SUB` when set, and updates Postman token `scope`.
123
+ `configure` does **not** rewrite application source. It ensures a `<project> Dev` login app (written to `.env` as `AUTH0_CLIENT_ID`), scans `projects/*/src` for `@Authorize("action", "Subject")`, adds those permissions to the Auth0 API (keeping any already on the API) and assigns them to `AUTH0_ADMIN_USER_SUB` when set.
124
+
125
+ #### Add Auth0 to an existing project
126
+
127
+ ```bash
128
+ decohere add auth0
129
+ ```
130
+
131
+ This logs in if needed, creates the Auth0 API and a `<project> Dev` login app, writes `AUTH0_ISSUER_BASE_URL`, `AUTH0_AUDIENCE` and `AUTH0_CLIENT_ID` to `.env`, adds the `auth` section to `config/config.yaml`, and adds `.withAuth()` to each API's `main.ts`. Running it again changes nothing. If a `main.ts` no longer has the generated shape, the command leaves it alone and prints the lines to add. It doesn't protect any routes for you, and it doesn't add the local user profile a new project with Postgres gets.
122
132
 
123
133
  #### Keep Auth0 in sync with controllers
124
134
 
@@ -128,7 +138,7 @@ decohere auth0 configure
128
138
  npx @decohere/create auth0 configure
129
139
  ```
130
140
 
131
- Then in Postman, Authorization → Get New Access Token so the token includes the new permissions.
141
+ Then get a new access token so it includes the new permissions.
132
142
 
133
143
  #### Deploy (Railway / Fly / Nixpacks)
134
144
 
@@ -185,17 +195,9 @@ override `defineAbilitiesFor` for product CASL rules, and `mapPrincipal` for IdP
185
195
  (including the `AUTH0_ADMIN_USER_SUB` admin bootstrap). `@decohere/http`'s default already maps
186
196
  `admin` → `manage`/`all` and `action:Subject` scopes.
187
197
 
188
- #### Postman (`--postman`)
198
+ #### Postman
189
199
 
190
- | Value | Effect |
191
- |---|---|
192
- | `none` | Skip Postman |
193
- | `local` | Local View collection + environment under `postman/` |
194
- | `api` | Create collection/environment in a Postman cloud workspace |
195
-
196
- ```bash
197
- npx @decohere/create webapi -d my-app --postman local
198
- ```
200
+ While the API is running, choose Import in Postman and paste `http://localhost:3000/openapi.json`. Import it again after you change a route.
199
201
 
200
202
  ## Options
201
203
 
@@ -204,11 +206,11 @@ npx @decohere/create webapi -d my-app --postman local
204
206
  | `[directory]` / `-d <directory>` | `webapi` / global | Target directory (positional wins; default `.`) |
205
207
  | `--name <slug>` | `webapi` | API directory under `projects/` (repeatable; default `api`) |
206
208
  | `add api <name>` | `decohere add api` / `npx @decohere/create webapi add` | Add an API to an existing Decohere workspace |
209
+ | `add auth0` | `decohere add auth0` / `npx @decohere/create add auth0` | Add Auth0 to an existing workspace |
207
210
  | `auth0 login` | `decohere auth0` / `npx @decohere/create auth0` | Device/URL login; persist tokens in `~/.config/auth0` |
208
- | `auth0 configure` | `decohere auth0` / `npx @decohere/create auth0` | Update Auth0 API + Postman SPA for an existing workspace |
211
+ | `auth0 configure` | `decohere auth0` / `npx @decohere/create auth0` | Update the Auth0 API and login app for an existing workspace |
209
212
  | `--database <provider>` | `webapi` / `add` | `none` \| `postgres/typeorm` |
210
213
  | `--auth <provider>` | `webapi` / `add` | `none` \| `auth0` |
211
- | `--postman <provider>` | `webapi` / `add` | `none` \| `local` \| `api` |
212
214
  | `-y, --yes` | `webapi` / `add` | Install dependencies without prompting |
213
215
  | `--install <mode>` | `webapi` / `add` | `ask` (default) \| `yes` \| `no` |
214
216
 
@@ -3,25 +3,40 @@ const HOST_FLAGS_WITH_VALUE = new Set([
3
3
  "--config-file",
4
4
  "--log-level"
5
5
  ]);
6
+ const PRODUCT_COMMANDS = new Set([
7
+ "create",
8
+ "add",
9
+ "auth0",
10
+ "help"
11
+ ]);
6
12
  /**
7
13
  * Map host / npm-create argv onto the product CLI (`create webapi` / `add api`).
8
14
  * `npm create @decohere webapi` already says “create”, so we prepend `create`
9
- * rather than making users type `create create webapi`.
15
+ * rather than making users type `create create webapi`. `webapi` is the only kind
16
+ * of project, so a first word that isn't a command is the project's folder.
10
17
  */ export function toProductArgv(tokens) {
11
- if (tokens[0] === "webapi" && tokens[1] === "add") {
18
+ const [first] = tokens;
19
+ if (first === "webapi" && tokens[1] === "add") {
12
20
  return [
13
21
  "add",
14
22
  "api",
15
23
  ...tokens.slice(2)
16
24
  ];
17
25
  }
18
- if (tokens[0] === "webapi") {
26
+ if (first === "webapi") {
19
27
  return [
20
28
  "create",
21
29
  "webapi",
22
30
  ...tokens.slice(1)
23
31
  ];
24
32
  }
33
+ if (first != null && !first.startsWith("-") && !PRODUCT_COMMANDS.has(first)) {
34
+ return [
35
+ "create",
36
+ "webapi",
37
+ ...tokens
38
+ ];
39
+ }
25
40
  return tokens;
26
41
  }
27
42
  export function containerArgvFromHost(argv) {
package/es6/src/runner.js CHANGED
@@ -13,11 +13,6 @@ const BUILDER_IMAGE = `${CREATE_IMAGE_REPOSITORY}:${CREATE_VERSION}`;
13
13
  mkdirSync(targetDir, {
14
14
  recursive: true
15
15
  });
16
- if (kind === "scaffold") {
17
- mkdirSync(resolve(targetDir, ".devcontainer", "npm-auth"), {
18
- recursive: true
19
- });
20
- }
21
16
  try {
22
17
  execFileSync("docker", [
23
18
  "info"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/create",
3
- "version": "0.0.1-dev.20261105.99",
3
+ "version": "0.0.1-dev.20261106.139",
4
4
  "description": "Download the Decohere scaffolder image and run it (npm create @decohere)",
5
5
  "keywords": [
6
6
  "decohere",
@@ -8,7 +8,8 @@ export type LaunchPlan = {
8
8
  /**
9
9
  * Map host / npm-create argv onto the product CLI (`create webapi` / `add api`).
10
10
  * `npm create @decohere webapi` already says “create”, so we prepend `create`
11
- * rather than making users type `create create webapi`.
11
+ * rather than making users type `create create webapi`. `webapi` is the only kind
12
+ * of project, so a first word that isn't a command is the project's folder.
12
13
  */
13
14
  export declare function toProductArgv(tokens: string[]): string[];
14
15
  export declare function containerArgvFromHost(argv: string[]): string[];
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- const _runner = require("./runner.js");
7
- (0, _runner.runInBuilder)(process.argv.slice(2));
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get containerArgvFromHost () {
13
- return _resolvelaunch.containerArgvFromHost;
14
- },
15
- get resolveLaunch () {
16
- return _resolvelaunch.resolveLaunch;
17
- },
18
- get runInBuilder () {
19
- return _runner.runInBuilder;
20
- },
21
- get toProductArgv () {
22
- return _resolvelaunch.toProductArgv;
23
- }
24
- });
25
- const _resolvelaunch = require("./resolve-launch.js");
26
- const _runner = require("./runner.js");
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get containerArgvFromHost () {
13
- return containerArgvFromHost;
14
- },
15
- get resolveLaunch () {
16
- return resolveLaunch;
17
- },
18
- get toProductArgv () {
19
- return toProductArgv;
20
- }
21
- });
22
- const _nodepath = require("node:path");
23
- const HOST_FLAGS_WITH_VALUE = new Set([
24
- "--config-file",
25
- "--log-level"
26
- ]);
27
- function toProductArgv(tokens) {
28
- if (tokens[0] === "webapi" && tokens[1] === "add") {
29
- return [
30
- "add",
31
- "api",
32
- ...tokens.slice(2)
33
- ];
34
- }
35
- if (tokens[0] === "webapi") {
36
- return [
37
- "create",
38
- "webapi",
39
- ...tokens.slice(1)
40
- ];
41
- }
42
- return tokens;
43
- }
44
- function containerArgvFromHost(argv) {
45
- const user = argv[0]?.includes("node") || argv[0]?.endsWith("node") ? argv.slice(2) : argv;
46
- const stripped = [];
47
- for(let i = 0; i < user.length; i++){
48
- const arg = user[i];
49
- if (arg != null && HOST_FLAGS_WITH_VALUE.has(arg)) {
50
- i++;
51
- continue;
52
- }
53
- if (arg != null) stripped.push(arg);
54
- }
55
- return toProductArgv(stripped);
56
- }
57
- function resolveLaunch(argv, cwd = process.cwd()) {
58
- if (argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h" || argv[0] === "--version")) {
59
- return {
60
- targetDir: cwd,
61
- containerArgv: argv,
62
- projectName: (0, _nodepath.basename)(cwd),
63
- kind: "scaffold"
64
- };
65
- }
66
- let directoryFlag;
67
- const withoutD = [];
68
- for(let i = 0; i < argv.length; i++){
69
- const arg = argv[i];
70
- if (arg === "-d") {
71
- directoryFlag = argv[i + 1];
72
- i++;
73
- continue;
74
- }
75
- if (arg != null) withoutD.push(arg);
76
- }
77
- const product = toProductArgv(withoutD);
78
- const isAdd = product[0] === "add";
79
- let positional;
80
- let withoutPositional = product;
81
- if (!isAdd && product[0] === "create" && product[1] === "webapi" && product[2] != null && !product[2].startsWith("-")) {
82
- positional = product[2];
83
- withoutPositional = [
84
- product[0],
85
- product[1],
86
- ...product.slice(3)
87
- ];
88
- }
89
- const targetDir = (0, _nodepath.resolve)(cwd, positional?.trim() || directoryFlag?.trim() || ".");
90
- return {
91
- targetDir,
92
- containerArgv: [
93
- ...withoutPositional,
94
- "-d",
95
- "."
96
- ],
97
- projectName: (0, _nodepath.basename)(targetDir),
98
- kind: product[0] === "auth0" ? "auth0" : "scaffold"
99
- };
100
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "runInBuilder", {
6
- enumerable: true,
7
- get: function() {
8
- return runInBuilder;
9
- }
10
- });
11
- const _nodechild_process = require("node:child_process");
12
- const _nodefs = require("node:fs");
13
- const _nodeos = require("node:os");
14
- const _nodepath = require("node:path");
15
- const _resolvelaunch = require("./resolve-launch.js");
16
- const _version = require("./version.js");
17
- const BUILDER_IMAGE = `${_version.CREATE_IMAGE_REPOSITORY}:${_version.CREATE_VERSION}`;
18
- function runInBuilder(argv) {
19
- const { targetDir, containerArgv, projectName, kind } = (0, _resolvelaunch.resolveLaunch)(argv);
20
- (0, _nodefs.mkdirSync)(targetDir, {
21
- recursive: true
22
- });
23
- if (kind === "scaffold") {
24
- (0, _nodefs.mkdirSync)((0, _nodepath.resolve)(targetDir, ".devcontainer", "npm-auth"), {
25
- recursive: true
26
- });
27
- }
28
- try {
29
- (0, _nodechild_process.execFileSync)("docker", [
30
- "info"
31
- ], {
32
- stdio: "pipe"
33
- });
34
- } catch {
35
- console.error("\n Docker is required to scaffold a Decohere project.\n" + " Install Docker Desktop: https://www.docker.com/products/docker-desktop\n");
36
- process.exit(1);
37
- }
38
- const hostUid = process.getuid?.();
39
- const hostGid = process.getgid?.() ?? hostUid;
40
- const runAsHostUser = hostUid != null && hostGid != null;
41
- const npmCacheDir = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".cache/decohere-create/npm");
42
- (0, _nodefs.mkdirSync)(npmCacheDir, {
43
- recursive: true
44
- });
45
- const builderHome = "/tmp/decohere-create-home";
46
- const volumes = [
47
- "-v",
48
- `${targetDir}:/workspace`,
49
- "-v",
50
- `${npmCacheDir}:/npm-cache`
51
- ];
52
- const envArgs = [
53
- "-e",
54
- "DECOHERE_BUILDER=1",
55
- "-e",
56
- `DECOHERE_PROJECT_NAME=${projectName}`,
57
- "-e",
58
- "NPM_CONFIG_CACHE=/npm-cache",
59
- "-e",
60
- "NPM_CONFIG_PREFER_OFFLINE=true",
61
- "-e",
62
- `HOME=${builderHome}`
63
- ];
64
- const npmrcPath = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".npmrc");
65
- if ((0, _nodefs.existsSync)(npmrcPath)) {
66
- volumes.push("-v", `${npmrcPath}:/tmp/host-npmrc:ro`);
67
- envArgs.push("-e", "NPM_CONFIG_USERCONFIG=/tmp/host-npmrc");
68
- }
69
- const auth0ConfigDir = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".config/auth0");
70
- (0, _nodefs.mkdirSync)(auth0ConfigDir, {
71
- recursive: true
72
- });
73
- volumes.push("-v", `${auth0ConfigDir}:${builderHome}/.config/auth0`);
74
- const userArgs = [];
75
- if (runAsHostUser) {
76
- userArgs.push("--user", `${hostUid}:${hostGid}`);
77
- } else if (hostUid != null) {
78
- envArgs.push("-e", `HOST_UID=${hostUid}`);
79
- if (hostGid != null) envArgs.push("-e", `HOST_GID=${hostGid}`);
80
- }
81
- console.log(kind === "auth0" ? " Running Auth0 CLI in the scaffolder image...\n" : " Running scaffolding in a sandboxed container...\n");
82
- const ttyFlags = process.stdin.isTTY ? [
83
- "-it"
84
- ] : [
85
- "-i"
86
- ];
87
- const result = (0, _nodechild_process.spawnSync)("docker", [
88
- "run",
89
- "--rm",
90
- ...ttyFlags,
91
- ...userArgs,
92
- ...volumes,
93
- ...envArgs,
94
- "-w",
95
- "/workspace",
96
- BUILDER_IMAGE,
97
- ...containerArgv
98
- ], {
99
- stdio: "inherit"
100
- });
101
- if (result.status === 0 && kind === "scaffold") {
102
- console.log(`\n Scaffold complete!\n\n Open your project:\n\n code ${targetDir}\n`);
103
- }
104
- process.exit(result.status ?? 0);
105
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get CREATE_IMAGE_REPOSITORY () {
13
- return CREATE_IMAGE_REPOSITORY;
14
- },
15
- get CREATE_VERSION () {
16
- return CREATE_VERSION;
17
- }
18
- });
19
- const _nodemodule = require("node:module");
20
- const _nodepath = require("node:path");
21
- const _nodeurl = require("node:url");
22
- const _require = (0, _nodemodule.createRequire)(require("url").pathToFileURL(__filename).toString());
23
- const DEFAULT_CREATE_VERSION = "0.0.1-dev";
24
- const DEFAULT_CREATE_IMAGE_REPOSITORY = "ghcr.io/typesmiths/decohere/create";
25
- function resolveCreateMetadata() {
26
- let dir = (0, _nodepath.dirname)((0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()));
27
- for(let i = 0; i < 5; i++){
28
- try {
29
- const pkg = _require((0, _nodepath.join)(dir, "package.json"));
30
- if (pkg.name === "@decohere/create") {
31
- return {
32
- version: pkg.version ?? DEFAULT_CREATE_VERSION,
33
- imageRepository: pkg.decohere?.dockerImageRepository ?? DEFAULT_CREATE_IMAGE_REPOSITORY
34
- };
35
- }
36
- } catch {}
37
- const parent = (0, _nodepath.dirname)(dir);
38
- if (parent === dir) break;
39
- dir = parent;
40
- }
41
- return {
42
- version: DEFAULT_CREATE_VERSION,
43
- imageRepository: DEFAULT_CREATE_IMAGE_REPOSITORY
44
- };
45
- }
46
- const createMetadata = resolveCreateMetadata();
47
- const CREATE_VERSION = createMetadata.version;
48
- const CREATE_IMAGE_REPOSITORY = createMetadata.imageRepository;