@foliwake/cli 0.8.0 → 0.10.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # @foliwake/cli
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ea82b05: `foliwake site preview-token --site <id>` shows a site's preview token (HTTP Basic user `preview`) for an app that
8
+ reads preview, as `FOLIWAKE_PREVIEW_TOKEN`. The server answers only site admins and writes an audit entry for every
9
+ answer, without the value (core `sites.previewToken`, in the contract synced from the engine). A server without
10
+ the operation says so.
11
+ - d53aa34: `npx @foliwake/next init` (bin `foliwake-next`, no extra dependencies) sets up a Next app: checks the site
12
+ (discovery, `X-Code-Release` on `/index.plain.html`), writes `FOLIWAKE_URL` to `.env.local`, wraps `next.config` in
13
+ `withFoliwake()` (two ES module forms; otherwise it prints the steps), and adds `app/foliwake/[...path]/route.ts`
14
+ and `app/[...path]/page.tsx`. `--preview` adds a preview route behind a development-only `isAuthor()` and an empty
15
+ `FOLIWAKE_PREVIEW_TOKEN=`; `--hook`, `--mount /pages`, `--dry-run`, `--json`, `--force` (only files it generated),
16
+ `--yes` (or `CI=1`; needs `--url`), `--ignore-git-changes`, and `--check` to check an existing setup. Exit codes 0,
17
+ 1 (error) and 2 (input needed); env equivalents `FOLIWAKE_INIT_*`. It never writes or prints a secret value.
18
+ `foliwake next init` in `@foliwake/cli` runs the same wizard.
19
+
20
+ ### Patch Changes
21
+
22
+ - 886f4b4: The command reference in the README escapes `<…>` in flag descriptions, so they show on npm and on the documentation site.
23
+ - Updated dependencies [339fb47]
24
+ - Updated dependencies [ea82b05]
25
+ - Updated dependencies [69caab7]
26
+ - Updated dependencies [df85d39]
27
+ - Updated dependencies [0bb04d6]
28
+ - @foliwake/blocks-contract@0.10.0
29
+ - @foliwake/server@0.10.0
30
+ - @foliwake/site-check@0.10.0
31
+ - @foliwake/core-contract@0.10.0
32
+ - @foliwake/block-kit@0.10.0
33
+ - create-foliwake@0.10.0
34
+
35
+ ## 0.9.0
36
+
37
+ ### Minor Changes
38
+
39
+ - 0cfb15c: Organisations and site deletion: `foliwake org list`, `foliwake org create <id> [--name]` (the installation's owner;
40
+ core `org.create`) and `foliwake site delete --site <id> [--confirm <id>] [--force]` (core `sites.delete`: refused
41
+ while the site works, has live pages or is named by memberships, invitations or CI keys; its bucket is kept and the
42
+ command says how to go on).
43
+
44
+ `site create`, `connect --create` and `create --create-site` never leave the organisation to the server: `--org`, or
45
+ the only organisation where the account may create sites (said), or asked in a terminal when there are several
46
+ (refused without one, listing them). `connect --create` gets `--org` and `--repository`; the repository defaults to
47
+ the folder's Git `origin` as an https:// address (`--repository none`: none). The "Next steps" after a new site no
48
+ longer mention SSH secrets: a public repository needs no code token, a private one a read token; the workflows take
49
+ a CI key made with `account keys create --site <id> --label github-actions`.
50
+
51
+ The core contract adds `org.create` and `sites.delete` and their error codes.
52
+ - 69dee17: `source add`: `--list-title` (Drupal, per `--language`), `--plugin google-docs` with `--page <document link or
53
+ ID>=<path>` (repeatable) and an optional `--folder`, and `--allow-private-host <host>` (the source's
54
+ `operator.allowPrivateHosts`; the installation's owner only). A source whose connection check fails is no longer
55
+ saved unless `--force`. When another source owns the whole site (`/`), it prints how to narrow that one first.
56
+ `source check` checks a new source described with the same flags (`--id …`) without saving it.
57
+
58
+ ### Patch Changes
59
+
60
+ - c8e7363: With the engine, `page check --content <dir>` (and every command with `--content`) in a folder linked to a site
61
+ checks the local files with the folder's `foliwake.config.json` instead of refusing: `--content` names a folder on
62
+ this computer, so it chooses the local runtime before the folder's link. `--server` with `--content` is still
63
+ refused.
64
+ - Updated dependencies [003f643]
65
+ - Updated dependencies [0cfb15c]
66
+ - Updated dependencies [5a7ffdf]
67
+ - Updated dependencies [6dd1fd4]
68
+ - @foliwake/server@0.9.0
69
+ - @foliwake/core-contract@0.9.0
70
+ - create-foliwake@0.9.0
71
+ - @foliwake/blocks-contract@0.9.0
72
+ - @foliwake/block-kit@0.9.0
73
+ - @foliwake/site-check@0.9.0
74
+
3
75
  ## 0.8.0
4
76
 
5
77
  ### Patch Changes
package/README.md CHANGED
@@ -127,6 +127,18 @@ engine and contract.
127
127
  renderer exists (the engine's `foliwake dev` has it).
128
128
  - `dev --remote` signs in to a protected site with HTTP Basic only, not with your `foliwake login`.
129
129
  - `dev --remote` shows no content errors: the content is the deployed site's, checked when it was published.
130
+ - `site create` / `connect --create` always name the organisation: the only one where you may create sites, or the
131
+ one chosen (`--org`, or asked in a terminal); a server still answers a call without `org` with its own default.
132
+ The repository defaults to the folder's Git `origin` as an https:// address; there is no check that the server
133
+ can fetch it until the first `code deploy --rev`.
134
+ - `site delete` keeps the site's bucket: the operator empties it before a site with the same id can be created.
135
+ Organisations cannot be renamed or deleted, and only the installation's owner creates them.
136
+ - `org list` / `org create` / `site delete` need a server with core `org.create` and `sites.delete`
137
+ (`PROCEDURE_UNKNOWN` on an older one).
138
+ - `source add` does not narrow another source for you: when the project's `content` source owns the whole site
139
+ (`/`), it prints the `site set … owns` to run first. `--allow-private-host` is accepted only from the
140
+ installation's owner, and only by a server that takes a new source's `operator` settings (older ones refuse
141
+ it at the field).
130
142
 
131
143
  ## Command reference
132
144
 
@@ -260,6 +272,10 @@ Link this project folder to a site on your Foliwake server: a new one or an exis
260
272
  - `--interactive` / --no-interactive: ask for what the flags leave open (default: only when stdin and stdout are a
261
273
  terminal)
262
274
  - `--link <value>`: link the folder to this existing site
275
+ - `--org <value>`: the new site's organisation (default: the only one where you may create sites; several: asked in a
276
+ terminal, refused without one)
277
+ - `--repository <value>`: the new site's repository (default: this folder's Git origin as an https:// address; `none`:
278
+ no repository yet)
263
279
 
264
280
  ### `foliwake create [folder]`
265
281
 
@@ -274,6 +290,7 @@ Create a new site frontend: blocks, styles, local pages, checks and workflows
274
290
  - `--interactive` / --no-interactive: ask for missing values (default: only when stdin and stdout are a terminal)
275
291
  - `--keep-existing`: the folder is not empty: add the project next to its files (refused if one would be replaced)
276
292
  - `--link-site <value>`: at the end, link the project to this existing site on your Foliwake server, as `site link`
293
+ - `--org <value>`: with --create-site: the site's organisation (default: the only one where you may create sites)
277
294
  - `--overwrite`: the folder is not empty: remove its files first (.git is kept)
278
295
  - `--react` / --no-react: add React support: React and ReactDOM vendored in scripts/vendor/ and the React example block
279
296
  poll; default: asked in a terminal, else no
@@ -356,6 +373,10 @@ Rebuild every live page against prepared code as the preview; live is unchanged
356
373
  - `--rev <value>`: the commit the code was prepared from, recorded with the preview
357
374
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
358
375
 
376
+ ### `foliwake next init`
377
+
378
+ Set up Foliwake pages in this Next.js app (runs `npx @foliwake/next init`)
379
+
359
380
  ### `foliwake operation cancel [id]`
360
381
 
361
382
  Ask a long operation to stop: a queued one stops at once, a running one when it can (core operations.cancel)
@@ -392,6 +413,17 @@ never runs an operation again (core operations.recover)
392
413
  is 3
393
414
  - `--wait-timeout <value>`: limit of --wait in seconds (default: settle delay + 90 s)
394
415
 
416
+ ### `foliwake org create [id]`
417
+
418
+ Create an organisation (the installation's owner only); your account becomes its admin. Sites are then created in it
419
+ with `site create --org <id>` (core org.create)
420
+
421
+ - `--name <value>`: the name people see (default: the id)
422
+
423
+ ### `foliwake org list`
424
+
425
+ The organisations you are a member of, with your role (the installation's owner sees every one; core org.list)
426
+
395
427
  ### `foliwake page changes`
396
428
 
397
429
  Compare working pages (text and images) with the live site (core content.changes)
@@ -494,9 +526,21 @@ Bind an existing bucket and its state to a configured site; publishes nothing (c
494
526
  Create this project's site on your Foliwake server (core sites.create; admin)
495
527
 
496
528
  - `--code` / --no-code: send the last commit for release 1 (--no-code: release 1 waits for the first code prepare)
497
- - `--org <value>`: the organisation (default: your only one where you are admin)
529
+ - `--org <value>`: the organisation (default: the only one where you may create sites; several: asked in a terminal,
530
+ refused without one)
498
531
  - `--relink`: replace the link of this folder (.foliwake/connection.json) to another server or site without asking
499
- - `--repository <value>`: where the code will live, e.g. https://github.com/acme/mytest (the server checkout's origin)
532
+ - `--repository <value>`: where the code lives, e.g. https://github.com/acme/mytest (the server checkout's origin;
533
+ default: this folder's Git origin as an https:// address; `none`: no repository yet)
534
+
535
+ ### `foliwake site delete`
536
+
537
+ Delete a site from the server (an admin of its organisation): its settings and history go, its state and checkout are
538
+ set aside, its bucket is kept for the operator to empty. Refused while it works, has live pages (unless --force) or
539
+ memberships, invitations or CI keys name it (core sites.delete)
540
+
541
+ - `--confirm <value>`: the site id, typed again: confirms without a question (needed without a terminal)
542
+ - `--force`: delete a site whose live release has pages (they stop being served)
543
+ - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
500
544
 
501
545
  ### `foliwake site edit`
502
546
 
@@ -522,6 +566,13 @@ Link this project folder to an existing site on your Foliwake server (developer
522
566
 
523
567
  Configured sites with hosts, repositories and bindings (core sites.list)
524
568
 
569
+ ### `foliwake site preview-token`
570
+
571
+ A site's preview token, for an app that reads preview (HTTP Basic, user preview); site admins only, and every answer is
572
+ written to the audit log without the value (core sites.previewToken)
573
+
574
+ - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
575
+
525
576
  ### `foliwake site reset-storage`
526
577
 
527
578
  Recreate a site's storage in one action: archive its state, delete its objects in its own bucket, bind both again,
@@ -565,19 +616,24 @@ Remove this project folder's link to its site (.foliwake/connection.json); the s
565
616
  Adds a content source to a site: checks it first (settings, credentials, connection, files and their addresses), then
566
617
  saves it after a confirmation; nothing is fetched (core sources.probe, sources.add)
567
618
 
619
+ - `--allow-private-host <value>`: a host on a private network the source may reach, e.g. a Drupal inside the server's
620
+ network (operator.allowPrivateHosts; the installation's owner only; repeatable)
568
621
  - `--base-url <value>`: Drupal: the site address
569
622
  - `--basic-password <value>`: Drupal: the credential name of its password
570
623
  - `--basic-user <value>`: Drupal: the credential name of a read-only user name (HTTP Basic)
571
624
  - `--branch <value>`: Git: the branch (default main)
572
625
  - `--check-only`: check and print, save nothing
573
626
  - `--display-name <value>`: the name the dashboard shows
574
- - `--folder <value>`: Google Drive: the folder link or ID
627
+ - `--folder <value>`: Google Drive or Google Docs: the folder link or ID
628
+ - `--force`: save even when the connection check fails
575
629
  - `--id <value>`: the new source id (lower case, digits, "-")
576
630
  - `--identity <value>`: Google Drive: file-id (default; renames keep the page) or front-matter
577
- - `--key <value>`: Google Drive: the credential name of the service-account key (default FOLIWAKE_GOOGLE_SA_KEY)
631
+ - `--key <value>`: Google Drive or Docs: the credential name of the service-account key (default FOLIWAKE_GOOGLE_SA_KEY)
578
632
  - `--language <value>`: Drupal: a language code, the default first (repeatable)
633
+ - `--list-title <value>`: Drupal: the heading of the article list page, per --language in the same order (repeatable)
579
634
  - `--mappings <value>`: a JSON file with path mapping rules (default: each file names its address)
580
635
  - `--owns <value>`: a path the source owns, such as /lessons or "=/" (repeatable)
636
+ - `--page <value>`: Google Docs: &lt;document link or ID&gt;=&lt;page path&gt;, one published page (repeatable)
581
637
  - `--plugin <value>`: the connector
582
638
  - `--repository <value>`: Git: the https address of the repository
583
639
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
@@ -596,13 +652,34 @@ paths it owns; preview and live are unchanged (core sources.adoptPages)
596
652
  ### `foliwake source check`
597
653
 
598
654
  Checks content sources without changing anything: settings, credentials, the connection and, with --listing, the files
599
- and the page addresses they would get (core sources.probe)
655
+ and the page addresses they would get; a saved source (--source) or a new one described with the flags of `source add`
656
+ (--id …) (core sources.probe)
600
657
 
658
+ - `--allow-private-host <value>`: a host on a private network the source may reach, e.g. a Drupal inside the server's
659
+ network (operator.allowPrivateHosts; the installation's owner only; repeatable)
660
+ - `--base-url <value>`: Drupal: the site address
661
+ - `--basic-password <value>`: Drupal: the credential name of its password
662
+ - `--basic-user <value>`: Drupal: the credential name of a read-only user name (HTTP Basic)
663
+ - `--branch <value>`: Git: the branch (default main)
664
+ - `--display-name <value>`: the name the dashboard shows
665
+ - `--folder <value>`: Google Drive or Google Docs: the folder link or ID
666
+ - `--id <value>`: the new source id (lower case, digits, "-")
667
+ - `--identity <value>`: Google Drive: file-id (default; renames keep the page) or front-matter
601
668
  - `--input <value>`: raw JSON for the full operation input; overrides the other input flags
669
+ - `--key <value>`: Google Drive or Docs: the credential name of the service-account key (default FOLIWAKE_GOOGLE_SA_KEY)
670
+ - `--language <value>`: Drupal: a language code, the default first (repeatable)
671
+ - `--list-title <value>`: Drupal: the heading of the article list page, per --language in the same order (repeatable)
602
672
  - `--listing`: also list the files and their page addresses (slower: reads the whole source)
673
+ - `--mappings <value>`: a JSON file with path mapping rules (default: each file names its address)
603
674
  - `--max <value>`: at most this many files in the listing (default 500)
675
+ - `--owns <value>`: a path the source owns, such as /lessons or "=/" (repeatable)
676
+ - `--page <value>`: Google Docs: &lt;document link or ID&gt;=&lt;page path&gt;, one published page (repeatable)
677
+ - `--plugin <value>`: the connector
678
+ - `--repository <value>`: Git: the https address of the repository
604
679
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
605
680
  - `--source <value>`: one source of the site (default: every enabled source)
681
+ - `--subfolder <value>`: Google Drive or Git: the folder inside that holds the pages
682
+ - `--token <value>`: Git: the credential name of a read-only token (private repository)
606
683
 
607
684
  ### `foliwake source list`
608
685
 
@@ -8,6 +8,8 @@ export default class Connect extends Command {
8
8
  create: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
9
  link: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  server: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ repository: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
14
  interactive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
15
  };
@@ -24,6 +24,7 @@ export default class Connect extends Command {
24
24
  static examples = [
25
25
  '<%= config.bin %> connect',
26
26
  '<%= config.bin %> connect --create mysite --server https://foliwake.example',
27
+ '<%= config.bin %> connect --create mysite --org acme --repository https://github.com/acme/mysite',
27
28
  '<%= config.bin %> connect --link docs-en --json',
28
29
  ];
29
30
  static enableJsonFlag = true;
@@ -33,6 +34,16 @@ export default class Connect extends Command {
33
34
  server: Flags.string({
34
35
  description: 'the Foliwake server (origin or host; default: $FOLIWAKE_SERVER, else asked or the only one)',
35
36
  }),
37
+ org: Flags.string({
38
+ dependsOn: ['create'],
39
+ description: "the new site's organisation (default: the only one where you may create sites; several: asked in a " +
40
+ 'terminal, refused without one)',
41
+ }),
42
+ repository: Flags.string({
43
+ dependsOn: ['create'],
44
+ description: "the new site's repository (default: this folder's Git origin as an https:// address; `none`: no " +
45
+ 'repository yet)',
46
+ }),
36
47
  force: Flags.boolean({ description: 'replace the link of a folder that is linked already' }),
37
48
  interactive: Flags.boolean({
38
49
  allowNo: true,
@@ -81,6 +92,8 @@ export default class Connect extends Command {
81
92
  linkSite: flags.link,
82
93
  server: flags.server === undefined ? undefined : this.originOf(flags.server),
83
94
  relink: flags.force,
95
+ org: flags.org,
96
+ repository: flags.repository,
84
97
  prompts: { input: process.stdin, output: process.stdout },
85
98
  signIn: signInHere,
86
99
  onLinked,
@@ -19,6 +19,7 @@ export default class Create extends Command {
19
19
  'link-site': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
20
  server: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
21
  relink: import("@oclif/core/interfaces").BooleanFlag<boolean>;
22
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
23
  connect: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
24
  interactive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
25
  help: import("@oclif/core/interfaces").BooleanFlag<void>;
@@ -72,6 +72,10 @@ At the end it can create or link the site on your Foliwake server (--create-site
72
72
  relink: Flags.boolean({
73
73
  description: 'with --create-site or --link-site in a folder already linked elsewhere: replace that link',
74
74
  }),
75
+ org: Flags.string({
76
+ dependsOn: ['create-site'],
77
+ description: "with --create-site: the site's organisation (default: the only one where you may create sites)",
78
+ }),
75
79
  connect: Flags.boolean({
76
80
  allowNo: true,
77
81
  description: '--no-connect: never ask «Connect to a Foliwake server?» (default: asked at the end in a terminal)',
@@ -159,6 +163,7 @@ At the end it can create or link the site on your Foliwake server (--create-site
159
163
  linkSite: flags['link-site'],
160
164
  server,
161
165
  relink: flags.relink,
166
+ org: flags.org,
162
167
  prompts: { input: process.stdin, output: process.stdout },
163
168
  signIn: (await import('../remote/sign-in-here.js')).signInHere,
164
169
  }, io);
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ /** The bin of the app's own @foliwake/next, or null when the app has none. */
3
+ export declare function installedInit(cwd: string): string | null;
4
+ export default class NextInit extends Command {
5
+ static summary: string;
6
+ static description: string;
7
+ static examples: string[];
8
+ static strict: boolean;
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,41 @@
1
+ // `foliwake next init`: the same wizard as `npx @foliwake/next init`, which lives in @foliwake/next. It runs the
2
+ // app's installed @foliwake/next when there is one, else that package at this CLI's exact version through npx.
3
+ import { spawnSync } from 'node:child_process';
4
+ import { readFileSync } from 'node:fs';
5
+ import { createRequire } from 'node:module';
6
+ import path from 'node:path';
7
+ import { Command } from '@oclif/core';
8
+ import { cliVersion } from '../../version.js';
9
+ /** The bin of the app's own @foliwake/next, or null when the app has none. */
10
+ export function installedInit(cwd) {
11
+ try {
12
+ const manifest = createRequire(path.join(cwd, 'package.json')).resolve('@foliwake/next/package.json');
13
+ const { bin } = JSON.parse(readFileSync(manifest, 'utf8'));
14
+ const file = bin?.['foliwake-next'];
15
+ return file ? path.resolve(path.dirname(manifest), file) : null;
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ }
21
+ export default class NextInit extends Command {
22
+ static summary = 'Set up Foliwake pages in this Next.js app (runs `npx @foliwake/next init`)';
23
+ static description = `Takes the same flags as \`npx @foliwake/next init\`; \`foliwake next init --help\` lists them.
24
+ Writes FOLIWAKE_URL to .env.local, wraps next.config in withFoliwake(), and adds one route file and one page.`;
25
+ static examples = [
26
+ '<%= config.bin %> next init --url https://my-site.example.org',
27
+ '<%= config.bin %> next init --url https://my-site.example.org --preview --dry-run',
28
+ ];
29
+ static strict = false;
30
+ async run() {
31
+ const args = ['init', ...this.argv];
32
+ const local = installedInit(process.cwd());
33
+ const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
34
+ const run = local
35
+ ? spawnSync(process.execPath, [local, ...args], { stdio: 'inherit' })
36
+ : spawnSync(npx, ['-y', `@foliwake/next@${cliVersion()}`, ...args], { stdio: 'inherit' });
37
+ if (run.error)
38
+ this.error(`Could not run @foliwake/next init: ${run.error.message}`, { exit: 1 });
39
+ this.exit(run.status ?? 1);
40
+ }
41
+ }
@@ -0,0 +1,13 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class OrgCreate extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<unknown>;
13
+ }
@@ -0,0 +1,30 @@
1
+ // `foliwake org create <id>`: a new organisation (core org.create; the installation's owner only).
2
+ import { Args, Flags } from '@oclif/core';
3
+ import { CoreCommand } from '../../core-command.js';
4
+ export default class OrgCreate extends CoreCommand {
5
+ static description = "Create an organisation (the installation's owner only); your account becomes its admin. Sites are then " +
6
+ 'created in it with `site create --org <id>` (core org.create)';
7
+ static examples = [
8
+ '<%= config.bin %> org create acme --name "Acme Ltd"',
9
+ '<%= config.bin %> org create acme --json',
10
+ ];
11
+ static args = {
12
+ id: Args.string({
13
+ required: true,
14
+ description: 'the organisation id: at most 12 lowercase letters, digits and single inner hyphens, starting with a ' +
15
+ 'letter (it is part of branch preview hosts and bucket names)',
16
+ }),
17
+ };
18
+ static flags = {
19
+ ...CoreCommand.configFlag,
20
+ name: Flags.string({ description: 'the name people see (default: the id)' }),
21
+ };
22
+ async run() {
23
+ const { args, flags } = await this.parse(OrgCreate);
24
+ const created = await this.core.org.create({ id: args.id, name: flags.name ?? args.id });
25
+ const role = created.membership ? `; you are its ${created.membership.role}` : '';
26
+ this.log(`Created organisation ${created.id} (${created.name})${role}.`);
27
+ this.log(`Create a site in it: \`foliwake site create <id> --org ${created.id}\`.`);
28
+ return created;
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class OrgList extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<unknown>;
9
+ }
@@ -0,0 +1,25 @@
1
+ // `foliwake org list`: the organisations of the signed-in account, with its role there (core org.list).
2
+ import { CoreCommand } from '../../core-command.js';
3
+ function lineOf(org) {
4
+ const name = org.name && org.name !== org.id ? ` (${org.name})` : '';
5
+ const member = org.membership;
6
+ if (!member)
7
+ return `${org.id}${name} installation, no membership`;
8
+ const live = member.role === 'developer' && member.live ? ', live' : '';
9
+ const sites = member.sites === null ? 'every site' : `sites ${member.sites.join(', ')}`;
10
+ return `${org.id}${name} ${member.role}${live}, ${sites}`;
11
+ }
12
+ export default class OrgList extends CoreCommand {
13
+ static description = "The organisations you are a member of, with your role (the installation's owner sees every one; core org.list)";
14
+ static examples = ['<%= config.bin %> org list', '<%= config.bin %> org list --json'];
15
+ static flags = { ...CoreCommand.configFlag };
16
+ async run() {
17
+ await this.parse(OrgList);
18
+ const orgs = await this.core.org.list();
19
+ for (const org of orgs)
20
+ this.log(lineOf(org));
21
+ if (orgs.length === 0)
22
+ this.log('No organisations.');
23
+ return orgs;
24
+ }
25
+ }
@@ -4,7 +4,8 @@ import { Args, Command, Flags } from '@oclif/core';
4
4
  export default class SiteCreate extends Command {
5
5
  static summary = "Create this project's site on your Foliwake server (core sites.create; admin)";
6
6
  static description = `In a project folder (as \`foliwake create\` makes it), signed in with \`foliwake login\` to ` +
7
- `any Foliwake server: creates the site in your organisation (you must be its admin), with release 1 from the ` +
7
+ `any Foliwake server: creates the site in an organisation where you are admin (--org; never chosen silently), ` +
8
+ `with its repository (--repository, default: the folder's Git origin), and release 1 from the ` +
8
9
  `folder's last commit (its code and pages, sent as a Git bundle), links the folder to it and prints what to ` +
9
10
  `set up next (GitHub, workflows, content sources). Nothing on GitHub is changed. To use a site that exists ` +
10
11
  `already: \`foliwake site link <id>\`.`;
@@ -28,9 +29,13 @@ export default class SiteCreate extends Command {
28
29
  relink: Flags.boolean({
29
30
  description: 'replace the link of this folder (.foliwake/connection.json) to another server or site without asking',
30
31
  }),
31
- org: Flags.string({ description: 'the organisation (default: your only one where you are admin)' }),
32
+ org: Flags.string({
33
+ description: 'the organisation (default: the only one where you may create sites; several: asked in a terminal, ' +
34
+ 'refused without one)',
35
+ }),
32
36
  repository: Flags.string({
33
- description: "where the code will live, e.g. https://github.com/acme/mytest (the server checkout's origin)",
37
+ description: "where the code lives, e.g. https://github.com/acme/mytest (the server checkout's origin; default: this " +
38
+ "folder's Git origin as an https:// address; `none`: no repository yet)",
34
39
  }),
35
40
  code: Flags.boolean({
36
41
  allowNo: true,
@@ -49,7 +54,7 @@ export default class SiteCreate extends Command {
49
54
  server: flags.server,
50
55
  site: args.id,
51
56
  org: flags.org,
52
- repository: flags.repository ?? null,
57
+ repository: flags.repository,
53
58
  code: flags.code,
54
59
  env: process.env,
55
60
  relink: flags.relink,
@@ -0,0 +1,14 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class SiteDelete extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ confirm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<unknown>;
12
+ /** The site id typed in a terminal; without one, --confirm is needed. */
13
+ private askSiteId;
14
+ }
@@ -0,0 +1,52 @@
1
+ // `foliwake site delete --site <id>`: remove a site from the server (core sites.delete). Its bucket is kept.
2
+ import { Flags } from '@oclif/core';
3
+ import { CoreCommand } from '../../core-command.js';
4
+ import { COMMAND } from '../../settings.js';
5
+ function resultLines(deleted) {
6
+ const pages = deleted.livePages > 0 ? ` Its ${deleted.livePages} live page(s) are no longer served here.` : '';
7
+ return [
8
+ `Deleted site ${deleted.site} (organisation ${deleted.org}) from the server.${pages}`,
9
+ `Its state and code checkout were set aside on the server (${deleted.foldersSetAside} folder(s), ` +
10
+ 'renamed `<folder>.deleted-<time>`); the operator removes them.',
11
+ "Its bucket was NOT touched: it still holds the site's pages and releases. The installation's operator " +
12
+ "empties or deletes it with the storage provider's tools; a site with this id can be created again only " +
13
+ 'after that.',
14
+ `A folder linked to it keeps its .foliwake/connection.json: \`${COMMAND} site unlink\` there.`,
15
+ ];
16
+ }
17
+ export default class SiteDelete extends CoreCommand {
18
+ static description = 'Delete a site from the server (an admin of its organisation): its settings and history go, its state and ' +
19
+ 'checkout are set aside, its bucket is kept for the operator to empty. Refused while it works, has live pages ' +
20
+ '(unless --force) or memberships, invitations or CI keys name it (core sites.delete)';
21
+ static examples = [
22
+ '<%= config.bin %> site delete --site old-site',
23
+ '<%= config.bin %> site delete --site old-site --confirm old-site --json',
24
+ ];
25
+ static flags = {
26
+ ...CoreCommand.siteFlags,
27
+ confirm: Flags.string({
28
+ description: 'the site id, typed again: confirms without a question (needed without a terminal)',
29
+ }),
30
+ force: Flags.boolean({ description: 'delete a site whose live release has pages (they stop being served)' }),
31
+ };
32
+ async run() {
33
+ const { flags } = await this.parse(SiteDelete);
34
+ const { site } = await this.siteInput(flags.site);
35
+ const confirm = flags.confirm ?? (await this.askSiteId(site));
36
+ const deleted = await this.core.sites.delete({ site, confirm, ...(flags.force ? { force: true } : {}) });
37
+ if (!this.jsonEnabled())
38
+ for (const line of resultLines(deleted))
39
+ this.log(line);
40
+ return deleted;
41
+ }
42
+ /** The site id typed in a terminal; without one, --confirm is needed. */
43
+ async askSiteId(site) {
44
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
45
+ this.error('Not a terminal: pass --confirm <site-id> to delete without being asked.', { exit: 2 });
46
+ const { isCancel, text } = await import('@clack/prompts');
47
+ const answer = await text({ message: `Type the site id (${site}) to delete the site`, placeholder: site });
48
+ if (isCancel(answer))
49
+ this.error('Cancelled; nothing was changed.', { exit: 1 });
50
+ return String(answer).trim();
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class SitePreviewToken extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<unknown>;
10
+ }
@@ -0,0 +1,18 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class SitePreviewToken extends CoreCommand {
3
+ static description = "A site's preview token, for an app that reads preview (HTTP Basic, user preview); site admins only, and " +
4
+ 'every answer is written to the audit log without the value (core sites.previewToken)';
5
+ static examples = [
6
+ '<%= config.bin %> site preview-token --site my-site',
7
+ '<%= config.bin %> site preview-token --site my-site --json',
8
+ ];
9
+ static flags = { ...CoreCommand.siteFlags };
10
+ async run() {
11
+ const { flags } = await this.parse(SitePreviewToken);
12
+ const answer = await this.core.sites.previewToken(await this.siteInput(flags.site));
13
+ this.log(`Preview token of ${answer.site} (HTTP Basic user "${answer.username}"; the server logged this request):`);
14
+ this.log(answer.token);
15
+ this.log("Put it in your app's server environment as FOLIWAKE_PREVIEW_TOKEN; never commit it.");
16
+ return answer;
17
+ }
18
+ }
@@ -1,12 +1,23 @@
1
+ import type { ProbeAnswer } from '../../core-types.js';
1
2
  import { CoreCommand } from '../../core-command.js';
3
+ /** The source that owns the whole site, when that is why the candidate was refused. */
4
+ export declare const wholeSiteOwner: (probe: ProbeAnswer) => string | null;
5
+ /**
6
+ * When another source owns the whole site (`/`, as the project's `content` source of a new site), how to make
7
+ * room: that source keeps the home page and the prefixes its pages use; the new source then owns its own.
8
+ */
9
+ export declare function ownershipHints(owner: string, index: number, site: string): string[];
2
10
  export default class SourceAdd extends CoreCommand {
3
11
  static description: string;
4
12
  static examples: string[];
5
13
  static flags: {
14
+ 'check-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
17
  plugin: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
- id: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
19
  'display-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- owns: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
20
+ owns: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
21
  mappings: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
22
  folder: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
23
  subfolder: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -19,13 +30,17 @@ export default class SourceAdd extends CoreCommand {
19
30
  language: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
31
  'basic-user': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
32
  'basic-password': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
- 'check-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
- yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
33
+ 'list-title': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ page: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ 'allow-private-host': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
36
  site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
37
  config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
38
  };
27
39
  run(): Promise<unknown>;
28
40
  private print;
41
+ private explainOwnership;
42
+ /** A source whose connection check failed is not saved unless --force. */
43
+ private refuseFailed;
29
44
  private finishCheck;
30
45
  /** --yes, or a person who says yes in a terminal; a failed connection is said before the question. */
31
46
  private confirmed;