@foliwake/cli 0.9.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 +32 -0
- package/README.md +13 -2
- package/dist/commands/next/init.d.ts +10 -0
- package/dist/commands/next/init.js +41 -0
- package/dist/commands/site/preview-token.d.ts +10 -0
- package/dist/commands/site/preview-token.js +18 -0
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
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
|
+
|
|
3
35
|
## 0.9.0
|
|
4
36
|
|
|
5
37
|
### 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:
|
|
636
|
+
- `--page <value>`: Google Docs: <document link or ID>=<page path>, 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:
|
|
676
|
+
- `--page <value>`: Google Docs: <document link or ID>=<page path>, 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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foliwake/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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",
|
|
@@ -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.
|
|
105
|
-
"@foliwake/
|
|
106
|
-
"@foliwake/server": "0.
|
|
107
|
-
"@foliwake/site-check": "0.
|
|
108
|
-
"create-foliwake": "0.
|
|
109
|
-
"@foliwake/
|
|
107
|
+
"@foliwake/block-kit": "0.10.0",
|
|
108
|
+
"@foliwake/core-contract": "0.10.0",
|
|
109
|
+
"@foliwake/server": "0.10.0",
|
|
110
|
+
"@foliwake/site-check": "0.10.0",
|
|
111
|
+
"create-foliwake": "0.10.0",
|
|
112
|
+
"@foliwake/blocks-contract": "0.10.0"
|
|
110
113
|
},
|
|
111
114
|
"files": [
|
|
112
115
|
"dist/",
|