@foliwake/cli 0.9.0 → 0.10.2

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,65 @@
1
1
  # @foliwake/cli
2
2
 
3
+ ## 0.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 964b5e5: Links point to the public documentation on foliwake.org (`docs.foliwake.org`, `sdk.foliwake.org`); the config
8
+ schemas' `$id` is under `https://foliwake.org/schemas/`.
9
+ - Updated dependencies [964b5e5]
10
+ - @foliwake/block-kit@0.10.2
11
+ - @foliwake/blocks-contract@0.10.2
12
+ - @foliwake/core-contract@0.10.2
13
+ - create-foliwake@0.10.2
14
+ - @foliwake/server@0.10.2
15
+ - @foliwake/site-check@0.10.2
16
+
17
+ ## 0.10.1
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [55ffb45]
22
+ - Updated dependencies [44822ad]
23
+ - Updated dependencies [e448fbb]
24
+ - @foliwake/server@0.10.1
25
+ - @foliwake/site-check@0.10.1
26
+ - create-foliwake@0.10.1
27
+ - @foliwake/block-kit@0.10.1
28
+ - @foliwake/blocks-contract@0.10.1
29
+ - @foliwake/core-contract@0.10.1
30
+
31
+ ## 0.10.0
32
+
33
+ ### Minor Changes
34
+
35
+ - ea82b05: `foliwake site preview-token --site <id>` shows a site's preview token (HTTP Basic user `preview`) for an app that
36
+ reads preview, as `FOLIWAKE_PREVIEW_TOKEN`. The server answers only site admins and writes an audit entry for every
37
+ answer, without the value (core `sites.previewToken`, in the contract synced from the engine). A server without
38
+ the operation says so.
39
+ - d53aa34: `npx @foliwake/next init` (bin `foliwake-next`, no extra dependencies) sets up a Next app: checks the site
40
+ (discovery, `X-Code-Release` on `/index.plain.html`), writes `FOLIWAKE_URL` to `.env.local`, wraps `next.config` in
41
+ `withFoliwake()` (two ES module forms; otherwise it prints the steps), and adds `app/foliwake/[...path]/route.ts`
42
+ and `app/[...path]/page.tsx`. `--preview` adds a preview route behind a development-only `isAuthor()` and an empty
43
+ `FOLIWAKE_PREVIEW_TOKEN=`; `--hook`, `--mount /pages`, `--dry-run`, `--json`, `--force` (only files it generated),
44
+ `--yes` (or `CI=1`; needs `--url`), `--ignore-git-changes`, and `--check` to check an existing setup. Exit codes 0,
45
+ 1 (error) and 2 (input needed); env equivalents `FOLIWAKE_INIT_*`. It never writes or prints a secret value.
46
+ `foliwake next init` in `@foliwake/cli` runs the same wizard.
47
+
48
+ ### Patch Changes
49
+
50
+ - 886f4b4: The command reference in the README escapes `<…>` in flag descriptions, so they show on npm and on the documentation site.
51
+ - Updated dependencies [339fb47]
52
+ - Updated dependencies [ea82b05]
53
+ - Updated dependencies [69caab7]
54
+ - Updated dependencies [df85d39]
55
+ - Updated dependencies [0bb04d6]
56
+ - @foliwake/blocks-contract@0.10.0
57
+ - @foliwake/server@0.10.0
58
+ - @foliwake/site-check@0.10.0
59
+ - @foliwake/core-contract@0.10.0
60
+ - @foliwake/block-kit@0.10.0
61
+ - create-foliwake@0.10.0
62
+
3
63
  ## 0.9.0
4
64
 
5
65
  ### Minor Changes
package/README.md CHANGED
@@ -373,6 +373,10 @@ Rebuild every live page against prepared code as the preview; live is unchanged
373
373
  - `--rev <value>`: the commit the code was prepared from, recorded with the preview
374
374
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
375
375
 
376
+ ### `foliwake next init`
377
+
378
+ Set up Foliwake pages in this Next.js app (runs `npx @foliwake/next init`)
379
+
376
380
  ### `foliwake operation cancel [id]`
377
381
 
378
382
  Ask a long operation to stop: a queued one stops at once, a running one when it can (core operations.cancel)
@@ -562,6 +566,13 @@ Link this project folder to an existing site on your Foliwake server (developer
562
566
 
563
567
  Configured sites with hosts, repositories and bindings (core sites.list)
564
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
+
565
576
  ### `foliwake site reset-storage`
566
577
 
567
578
  Recreate a site's storage in one action: archive its state, delete its objects in its own bucket, bind both again,
@@ -622,7 +633,7 @@ saves it after a confirmation; nothing is fetched (core sources.probe, sources.a
622
633
  - `--list-title <value>`: Drupal: the heading of the article list page, per --language in the same order (repeatable)
623
634
  - `--mappings <value>`: a JSON file with path mapping rules (default: each file names its address)
624
635
  - `--owns <value>`: a path the source owns, such as /lessons or "=/" (repeatable)
625
- - `--page <value>`: Google Docs: <document link or ID>=<page path>, one published page (repeatable)
636
+ - `--page <value>`: Google Docs: &lt;document link or ID&gt;=&lt;page path&gt;, one published page (repeatable)
626
637
  - `--plugin <value>`: the connector
627
638
  - `--repository <value>`: Git: the https address of the repository
628
639
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
@@ -662,7 +673,7 @@ and the page addresses they would get; a saved source (--source) or a new one de
662
673
  - `--mappings <value>`: a JSON file with path mapping rules (default: each file names its address)
663
674
  - `--max <value>`: at most this many files in the listing (default 500)
664
675
  - `--owns <value>`: a path the source owns, such as /lessons or "=/" (repeatable)
665
- - `--page <value>`: Google Docs: <document link or ID>=<page path>, one published page (repeatable)
676
+ - `--page <value>`: Google Docs: &lt;document link or ID&gt;=&lt;page path&gt;, one published page (repeatable)
666
677
  - `--plugin <value>`: the connector
667
678
  - `--repository <value>`: Git: the https address of the repository
668
679
  - `--site <value>`: site id (default: the site this folder is linked to, else the only site on the server)
@@ -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,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
+ }
@@ -42,7 +42,7 @@ export declare function serverOrigin(typed: string, env?: NodeJS.ProcessEnv): st
42
42
  export declare function serverName(origin: string, env?: NodeJS.ProcessEnv): string;
43
43
  /** The origin of a remembered name ("cloud" or an origin); null for a name that is neither. */
44
44
  export declare function nameOrigin(name: string, env?: NodeJS.ProcessEnv): string | null;
45
- /** How a server is printed: "cloud (https://foliwake.dev)" for the cloud, else its origin. */
45
+ /** How a server is printed: "cloud (https://cloud.foliwake.org)" for the cloud, else its origin. */
46
46
  export declare function serverDisplay(origin: string, env?: NodeJS.ProcessEnv): string;
47
47
  export declare function readProfiles(env?: NodeJS.ProcessEnv): Profiles;
48
48
  export declare function writeProfiles(profiles: Profiles, env?: NodeJS.ProcessEnv): void;
@@ -45,7 +45,7 @@ export function nameOrigin(name, env = process.env) {
45
45
  return null;
46
46
  }
47
47
  }
48
- /** How a server is printed: "cloud (https://foliwake.dev)" for the cloud, else its origin. */
48
+ /** How a server is printed: "cloud (https://cloud.foliwake.org)" for the cloud, else its origin. */
49
49
  export function serverDisplay(origin, env = process.env) {
50
50
  return serverName(origin, env) === CLOUD ? `${CLOUD} (${origin})` : origin;
51
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foliwake/cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.2",
4
4
  "description": "The foliwake command without the engine: sign in to a Foliwake server and run its commands there (site status, sync, preview, publish, code deploy, branches, releases, sources, credentials, CI keys), and develop blocks against a remote preview.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/foliwake/foliwake-js.git",
14
14
  "directory": "packages/cli"
15
15
  },
16
- "homepage": "https://sdk.foliwake.dev/reference/packages/cli",
16
+ "homepage": "https://sdk.foliwake.org/reference/packages/cli",
17
17
  "bugs": {
18
18
  "url": "https://github.com/foliwake/foliwake-js/issues"
19
19
  },
@@ -67,6 +67,9 @@
67
67
  "credential": {
68
68
  "description": "Credential values the content sources name (stored on the server, never shown)"
69
69
  },
70
+ "next": {
71
+ "description": "Next.js apps that show Foliwake pages"
72
+ },
70
73
  "migration": {
71
74
  "description": "Whole-site rebuilds against new code, released as one"
72
75
  },
@@ -101,12 +104,12 @@
101
104
  "@oclif/core": "4.14.0",
102
105
  "chokidar": "6.0.0",
103
106
  "parse5": "7.3.0",
104
- "@foliwake/block-kit": "0.9.0",
105
- "@foliwake/blocks-contract": "0.9.0",
106
- "@foliwake/server": "0.9.0",
107
- "@foliwake/site-check": "0.9.0",
108
- "create-foliwake": "0.9.0",
109
- "@foliwake/core-contract": "0.9.0"
107
+ "@foliwake/blocks-contract": "0.10.2",
108
+ "@foliwake/server": "0.10.2",
109
+ "@foliwake/core-contract": "0.10.2",
110
+ "create-foliwake": "0.10.2",
111
+ "@foliwake/site-check": "0.10.2",
112
+ "@foliwake/block-kit": "0.10.2"
110
113
  },
111
114
  "files": [
112
115
  "dist/",