@starcier/create-builder 1.0.0-next.0 → 1.0.0-next.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/README.md CHANGED
@@ -26,18 +26,24 @@ Until `1.0.0` is released, use `@next` as above.
26
26
 
27
27
  ### Connection settings
28
28
 
29
- These do not change between clients, so set them once as environment variables rather than
30
- passing them every time:
29
+ These do not change between clients, so they are **built in** and you never type them. Override
30
+ one only to point somewhere else, such as a local API, with an option or an environment variable:
31
31
 
32
32
  | Variable | Option | What |
33
33
  | --- | --- | --- |
34
34
  | `STARCIER_API_URL` | `--api-url` | The API's origin |
35
35
  | `STARCIER_AUTH0_DOMAIN` | `--auth0-domain` | The Auth0 tenant's domain |
36
- | `STARCIER_AUTH0_AUDIENCE` | `--auth0-audience` | The API's audience; defaults to `https://starcier-api` |
36
+ | `STARCIER_AUTH0_AUDIENCE` | `--auth0-audience` | The API's audience |
37
37
  | `STARCIER_AUTH0_CLIENT_ID` | `--auth0-client-id` | The builders' single-page application, written into the builder's `.env` |
38
38
  | `STARCIER_AUTH0_CLI_CLIENT_ID` | `--cli-client-id` | The native application this command signs in with |
39
39
  | `STARCIER_TOKEN` | `--token` | An API access token, used instead of signing in |
40
40
 
41
+ The built-in values point at Starcier's dev environment until production goes live.
42
+
43
+ **Signing in.** Until the command's own Auth0 application exists, it cannot sign you in through
44
+ the browser, so it needs your access token: sign in to the Starcier builder, copy the token, and
45
+ set it as `STARCIER_TOKEN` for the terminal you run the command in.
46
+
41
47
  ## What it guarantees
42
48
 
43
49
  - **Nothing half-created.** The files are prepared aside and moved into place only after the
package/dist/args.js CHANGED
@@ -73,5 +73,7 @@ Options:
73
73
  --offline Create the files only: no sign-in, no tenant
74
74
  -h, --help Show this help
75
75
 
76
- Creating the tenant needs a Starcier staff account. Anything not given is asked for.
76
+ The name, slug and folder are asked for when not given. The API and Auth0
77
+ settings are built in, so leave them out unless pointing somewhere else.
78
+ Creating the tenant needs a Starcier staff account.
77
79
  `;
package/dist/cli.js CHANGED
File without changes
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Where a new builder connects when nothing else is given. These are the same
3
+ * for every client, so an operator never has to know or type them; flags and
4
+ * `STARCIER_*` variables still win, e.g. to point at a local API.
5
+ *
6
+ * Today they are the dev environment's, the only one that exists. At go-live
7
+ * they become production's (deploy-to-production.md, "Client builders").
8
+ */
9
+ export const DEFAULTS = {
10
+ apiUrl: 'https://starcier-design-system-dev.up.railway.app',
11
+ auth0Domain: 'dev-k7pyqn8upxwm2wgi.us.auth0.com',
12
+ auth0Audience: 'https://starcier-design-system-api',
13
+ spaClientId: 'tqVw1OE5L4ElaTeKtnKfynBr2rIWNeY7',
14
+ cliClientId: undefined,
15
+ };
package/dist/main.js CHANGED
@@ -4,10 +4,10 @@ import { basename, dirname, join, relative, resolve } from 'node:path';
4
4
  import { createTenant, normaliseApiUrl } from './api.js';
5
5
  import { flagFor, parseArgs, USAGE } from './args.js';
6
6
  import { pollForToken, requestDeviceCode } from './auth.js';
7
+ import { DEFAULTS } from './defaults.js';
7
8
  import { CliError } from './errors.js';
8
9
  import { slugProblem, suggestSlug } from './slug.js';
9
10
  import { configureBuilder, renderTemplate } from './template.js';
10
- const DEFAULT_AUDIENCE = 'https://starcier-api';
11
11
  const defaultGitInit = (dir) => {
12
12
  spawnSync('git', ['init', '--quiet'], { cwd: dir, stdio: 'ignore' });
13
13
  };
@@ -23,15 +23,6 @@ async function askValid(prompter, question, problem) {
23
23
  }
24
24
  }
25
25
  const required = (label) => (value) => (value ? null : `${label} is required.`);
26
- function urlProblem(value) {
27
- try {
28
- const url = new URL(value);
29
- return url.protocol === 'https:' || url.protocol === 'http:' ? null : 'Use an http(s) address.';
30
- }
31
- catch {
32
- return 'That is not a valid address.';
33
- }
34
- }
35
26
  async function assertUsable(target) {
36
27
  const entries = await readdir(target).catch((err) => {
37
28
  if (err.code === 'ENOENT')
@@ -41,14 +32,21 @@ async function assertUsable(target) {
41
32
  if (entries.length > 0)
42
33
  throw new CliError(`${target} is not empty. Choose a new folder.`);
43
34
  }
44
- /** Everything the online path needs, from flags, environment variables or questions. */
45
- async function resolveConnection(options, prompter) {
46
- const value = (key, message, check = required(message)) => options[key] ? Promise.resolve(options[key]) : askValid(prompter, { message, flag: flagFor(key) }, check);
47
- const apiUrl = normaliseApiUrl(await value('apiUrl', 'Starcier API address', (v) => required('The API address')(v) ?? urlProblem(v)));
48
- const auth0Domain = await value('auth0Domain', 'Auth0 domain');
49
- const auth0Audience = options.auth0Audience || DEFAULT_AUDIENCE;
50
- const spaClientId = await value('spaClientId', "The builders' Auth0 client id");
51
- const cliClientId = options.token ? undefined : await value('cliClientId', "This command's Auth0 client id");
35
+ /**
36
+ * Everything the online path needs: flags and environment variables, else the
37
+ * built-in defaults, so nothing here is ever asked. Signing in needs either a
38
+ * token or the command's own Auth0 application.
39
+ */
40
+ function resolveConnection(options) {
41
+ const apiUrl = normaliseApiUrl(options.apiUrl || DEFAULTS.apiUrl);
42
+ const auth0Domain = options.auth0Domain || DEFAULTS.auth0Domain;
43
+ const auth0Audience = options.auth0Audience || DEFAULTS.auth0Audience;
44
+ const spaClientId = options.spaClientId || DEFAULTS.spaClientId;
45
+ const cliClientId = options.token ? undefined : options.cliClientId || DEFAULTS.cliClientId;
46
+ if (!options.token && !cliClientId) {
47
+ throw new CliError('Signing in through the browser is not set up yet. Sign in to the Starcier builder, copy your access ' +
48
+ `token, and pass it with ${flagFor('token')} or the STARCIER_TOKEN environment variable.`);
49
+ }
52
50
  return { apiUrl, auth0Domain, auth0Audience, spaClientId, cliClientId };
53
51
  }
54
52
  async function signIn(config, deps) {
@@ -89,7 +87,7 @@ export async function run(deps) {
89
87
  const dir = options.dir || (await prompter.ask({ message: 'Folder', default: `${slug}-builder`, flag: 'a folder argument' }));
90
88
  const target = resolve(deps.cwd, dir);
91
89
  await assertUsable(target);
92
- const connection = options.offline ? null : await resolveConnection(options, prompter);
90
+ const connection = options.offline ? null : resolveConnection(options);
93
91
  await mkdir(dirname(target), { recursive: true });
94
92
  const staging = await mkdtemp(join(dirname(target), `.${basename(target)}-`));
95
93
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starcier/create-builder",
3
- "version": "1.0.0-next.0",
3
+ "version": "1.0.0-next.1",
4
4
  "description": "Creates a Starcier prototype builder for a client: registers its tenant with the Starcier API and writes a repository with a starter design system. Run with `npm create @starcier/builder`.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@auth0/auth0-react": "^2.22.1",
14
14
  "@starcier/builder-shell": "^1.0.0-next.1",
15
- "@starcier/collab-core": "^1.0.0-next.1",
15
+ "@starcier/collab-core": "^1.0.0-next.3",
16
16
  "@starcier/collab-ui": "^1.0.0-next.1",
17
17
  "react": "^19.2.0",
18
18
  "react-dom": "^19.2.0",