@byline/cli 6.6.0 → 6.7.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/dist/lib/template-docs-hooks.test.node.d.ts +9 -0
- package/dist/lib/template-docs-hooks.test.node.d.ts.map +1 -0
- package/dist/lib/template-docs-hooks.test.node.js +98 -0
- package/dist/lib/template-docs-hooks.test.node.js.map +1 -0
- package/dist/lib/template-pages-preview.test.node.d.ts +9 -0
- package/dist/lib/template-pages-preview.test.node.d.ts.map +1 -0
- package/dist/lib/template-pages-preview.test.node.js +55 -0
- package/dist/lib/template-pages-preview.test.node.js.map +1 -0
- package/dist/templates/byline-examples/collections/docs/admin.tsx +7 -0
- package/dist/templates/byline-examples/collections/docs/hooks.ts +5 -2
- package/dist/templates/byline-examples/collections/news/admin.tsx +7 -0
- package/dist/templates/byline-examples/collections/pages/admin.tsx +9 -1
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=template-docs-hooks.test.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-docs-hooks.test.node.d.ts","sourceRoot":"","sources":["../../src/lib/template-docs-hooks.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
9
|
+
const search = vi.hoisted(() => ({
|
|
10
|
+
collection: vi.fn(),
|
|
11
|
+
indexDocument: vi.fn(),
|
|
12
|
+
}));
|
|
13
|
+
vi.mock('@byline/client/server', () => ({
|
|
14
|
+
getSystemBylineClient: () => ({ collection: search.collection }),
|
|
15
|
+
}));
|
|
16
|
+
// The template imports `@byline/client/server`, which is not a CLI dependency
|
|
17
|
+
// (it is mocked above), and `src/templates` is excluded from the CLI's
|
|
18
|
+
// TypeScript program. A runtime-only specifier keeps the compiler from
|
|
19
|
+
// following the import while Vitest still resolves and loads the module.
|
|
20
|
+
const templateHooksPath = '../templates/byline-examples/collections/docs/hooks.js';
|
|
21
|
+
let hooks;
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
hooks = (await import(/* @vite-ignore */ templateHooksPath)).default;
|
|
24
|
+
});
|
|
25
|
+
function context(overrides) {
|
|
26
|
+
return {
|
|
27
|
+
documentId: 'doc-1',
|
|
28
|
+
collectionPath: 'docs',
|
|
29
|
+
requested: { path: false, availableLocales: false },
|
|
30
|
+
changed: { path: false, availableLocales: false },
|
|
31
|
+
reconciliation: false,
|
|
32
|
+
previousPath: 'intro',
|
|
33
|
+
currentPath: 'intro',
|
|
34
|
+
previousAvailableLocales: ['en'],
|
|
35
|
+
currentAvailableLocales: ['en'],
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function run(ctx) {
|
|
40
|
+
const hook = hooks.afterSystemFieldsChange;
|
|
41
|
+
expect(hook).toBeDefined();
|
|
42
|
+
for (const fn of Array.isArray(hook) ? hook : hook ? [hook] : [])
|
|
43
|
+
await fn(ctx);
|
|
44
|
+
}
|
|
45
|
+
describe('scaffolded docs afterSystemFieldsChange', () => {
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
vi.clearAllMocks();
|
|
48
|
+
vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
49
|
+
search.indexDocument.mockResolvedValue(undefined);
|
|
50
|
+
search.collection.mockReturnValue({ indexDocument: search.indexDocument });
|
|
51
|
+
});
|
|
52
|
+
it.each([
|
|
53
|
+
['enabled', ['en'], ['en', 'es']],
|
|
54
|
+
['disabled', ['en', 'es'], ['en']],
|
|
55
|
+
])('reindexes once when a locale is %s and the path is untouched', async (_name, before, after) => {
|
|
56
|
+
await run(context({
|
|
57
|
+
requested: { path: false, availableLocales: true },
|
|
58
|
+
changed: { path: false, availableLocales: true },
|
|
59
|
+
previousAvailableLocales: before,
|
|
60
|
+
currentAvailableLocales: after,
|
|
61
|
+
}));
|
|
62
|
+
expect(search.collection).toHaveBeenCalledWith('docs');
|
|
63
|
+
expect(search.indexDocument).toHaveBeenCalledOnce();
|
|
64
|
+
expect(search.indexDocument).toHaveBeenCalledWith('doc-1');
|
|
65
|
+
});
|
|
66
|
+
it('reindexes once for a path change, or a combined path and locale change', async () => {
|
|
67
|
+
await run(context({
|
|
68
|
+
requested: { path: true, availableLocales: false },
|
|
69
|
+
changed: { path: true, availableLocales: false },
|
|
70
|
+
currentPath: 'introduction',
|
|
71
|
+
}));
|
|
72
|
+
await run(context({
|
|
73
|
+
requested: { path: true, availableLocales: true },
|
|
74
|
+
changed: { path: true, availableLocales: true },
|
|
75
|
+
currentPath: 'introduction',
|
|
76
|
+
currentAvailableLocales: ['en', 'es'],
|
|
77
|
+
}));
|
|
78
|
+
expect(search.indexDocument).toHaveBeenCalledTimes(2);
|
|
79
|
+
});
|
|
80
|
+
it('re-runs indexing on an explicit no-op locale reconciliation retry', async () => {
|
|
81
|
+
await run(context({
|
|
82
|
+
requested: { path: false, availableLocales: true },
|
|
83
|
+
changed: { path: false, availableLocales: false },
|
|
84
|
+
reconciliation: true,
|
|
85
|
+
}));
|
|
86
|
+
expect(search.indexDocument).toHaveBeenCalledOnce();
|
|
87
|
+
});
|
|
88
|
+
it('surfaces an indexing failure so the committed-hook flow can report and retry it', async () => {
|
|
89
|
+
const failure = new Error('index unavailable');
|
|
90
|
+
search.indexDocument.mockRejectedValueOnce(failure);
|
|
91
|
+
await expect(run(context({
|
|
92
|
+
requested: { path: false, availableLocales: true },
|
|
93
|
+
changed: { path: false, availableLocales: true },
|
|
94
|
+
currentAvailableLocales: ['en', 'es'],
|
|
95
|
+
}))).rejects.toBe(failure);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=template-docs-hooks.test.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-docs-hooks.test.node.js","sourceRoot":"","sources":["../../src/lib/template-docs-hooks.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAExE,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/B,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;IACnB,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;CACvB,CAAC,CAAC,CAAA;AAEH,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC;IACtC,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;CACjE,CAAC,CAAC,CAAA;AAIH,8EAA8E;AAC9E,uEAAuE;AACvE,uEAAuE;AACvE,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,wDAAwD,CAAA;AAClF,IAAI,KAA0E,CAAA;AAE9E,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAA;AACtE,CAAC,CAAC,CAAA;AAEF,SA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distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=template-pages-preview.test.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-pages-preview.test.node.d.ts","sourceRoot":"","sources":["../../src/lib/template-pages-preview.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Runtime test of the scaffolded Pages preview builder (the file generated
|
|
10
|
+
* projects receive). The prefix must follow the content default locale, never
|
|
11
|
+
* the admin interface default, and the selected content locale must survive
|
|
12
|
+
* even when it is not advertised.
|
|
13
|
+
*/
|
|
14
|
+
import { beforeAll, describe, expect, it, vi } from 'vitest';
|
|
15
|
+
// Admin and content defaults deliberately differ.
|
|
16
|
+
vi.mock('~/i18n', () => ({
|
|
17
|
+
i18n: {
|
|
18
|
+
admin: { defaultLocale: 'en', locales: ['en', 'fr'] },
|
|
19
|
+
content: { defaultLocale: 'fr', locales: ['fr', 'en', 'es'] },
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
// The admin config is data plus React components; only `preview.url` matters.
|
|
23
|
+
vi.mock('@byline/core', async (importOriginal) => ({
|
|
24
|
+
...(await importOriginal()),
|
|
25
|
+
defineAdmin: (_definition, config) => config,
|
|
26
|
+
}));
|
|
27
|
+
vi.mock('@byline/admin/react', () => ({ DateTimeFormatter: () => null }));
|
|
28
|
+
vi.mock('~/components/summary-length.js', () => ({ SummaryLength: () => null }));
|
|
29
|
+
// `src/templates` is excluded from the CLI's TypeScript program; a runtime-only
|
|
30
|
+
// specifier keeps the compiler from following the import (see the docs hooks test).
|
|
31
|
+
const templateAdminPath = '../templates/byline-examples/collections/pages/admin.js';
|
|
32
|
+
let url;
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
const module = await import(/* @vite-ignore */ templateAdminPath);
|
|
35
|
+
const preview = module.PagesAdmin.preview;
|
|
36
|
+
if (preview == null)
|
|
37
|
+
throw new Error('template Pages admin has no preview builder');
|
|
38
|
+
url = preview.url;
|
|
39
|
+
});
|
|
40
|
+
function page(path, area) {
|
|
41
|
+
return { id: 'doc-1', path, status: 'draft', fields: area ? { area } : {} };
|
|
42
|
+
}
|
|
43
|
+
describe('scaffolded Pages preview URL', () => {
|
|
44
|
+
it('omits the prefix for the content default locale, even though admin defaults to en', () => {
|
|
45
|
+
expect(url(page('team'), { locale: 'fr' })).toBe('/team');
|
|
46
|
+
});
|
|
47
|
+
it('prefixes every other content locale, including the admin default', () => {
|
|
48
|
+
expect(url(page('team'), { locale: 'en' })).toBe('/en/team');
|
|
49
|
+
expect(url(page('team'), { locale: 'es' })).toBe('/es/team');
|
|
50
|
+
});
|
|
51
|
+
it('hides the affordance until the page has a path', () => {
|
|
52
|
+
expect(url(page(''), { locale: 'es' })).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=template-pages-preview.test.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-pages-preview.test.node.js","sourceRoot":"","sources":["../../src/lib/template-pages-preview.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE5D,kDAAkD;AAClD,EAAE,CAAC,IAAI,CAAC,QAAQ,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AAY,EAAE,IAAa;IACvC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAC7E,CAAC;AAED,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,EAAE,CAAC,mFAAmF,EAAE,GAAG,EAAE;QAC3F,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC5D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACpD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -129,6 +129,13 @@ export const DocsAdmin: CollectionAdminConfig = defineAdmin(Docs, {
|
|
|
129
129
|
* Direct relations are auto-populated by the edit view (depth 1, picker
|
|
130
130
|
* projection) and appear under `doc.fields.<name>?.document`.
|
|
131
131
|
*
|
|
132
|
+
* `locale` is the content locale selected in the editor. Keep it even when
|
|
133
|
+
* that translation is not advertised: preview is how an editor reviews an
|
|
134
|
+
* unchecked translation. The locale prefix must follow your public routes'
|
|
135
|
+
* rule, which this scaffold cannot know; the example assumes the default
|
|
136
|
+
* locale (`'en'`) is unprefixed. Never derive it from the admin interface
|
|
137
|
+
* language.
|
|
138
|
+
*
|
|
132
139
|
* @example
|
|
133
140
|
* preview: {
|
|
134
141
|
* url: (doc, { locale }) => {
|
|
@@ -78,8 +78,11 @@ export default defineHooks({
|
|
|
78
78
|
`afterSystemFieldsChange: ${documentId} in '${collectionPath}' changed`,
|
|
79
79
|
changed
|
|
80
80
|
)
|
|
81
|
-
//
|
|
82
|
-
|
|
81
|
+
// Both change the public index: a path change moves the indexed URL, and
|
|
82
|
+
// an advertised-locale change alters which translations are publicly
|
|
83
|
+
// delivered (and so indexed). Check `requested` rather than `changed` so an
|
|
84
|
+
// explicit reconciliation retry re-runs indexing after a failed attempt.
|
|
85
|
+
if (requested.path || requested.availableLocales) {
|
|
83
86
|
await getSystemBylineClient().collection('docs').indexDocument(documentId)
|
|
84
87
|
}
|
|
85
88
|
},
|
|
@@ -140,6 +140,13 @@ export const NewsAdmin: CollectionAdminConfig = defineAdmin(News, {
|
|
|
140
140
|
* Direct relations are auto-populated by the edit view (depth 1, picker
|
|
141
141
|
* projection) and appear under `doc.fields.<name>?.document`.
|
|
142
142
|
*
|
|
143
|
+
* `locale` is the content locale selected in the editor. Keep it even when
|
|
144
|
+
* that translation is not advertised: preview is how an editor reviews an
|
|
145
|
+
* unchecked translation. The locale prefix must follow your public routes'
|
|
146
|
+
* rule, which this scaffold cannot know; the example assumes the default
|
|
147
|
+
* locale (`'en'`) is unprefixed. Never derive it from the admin interface
|
|
148
|
+
* language.
|
|
149
|
+
*
|
|
143
150
|
* @example
|
|
144
151
|
* preview: {
|
|
145
152
|
* url: (doc, { locale }) => {
|
|
@@ -125,6 +125,14 @@ export const PagesAdmin: CollectionAdminConfig = defineAdmin(Pages, {
|
|
|
125
125
|
* richtext embed walker on internal-link nodes) and adds the request-
|
|
126
126
|
* locale prefix on top. Returns `null` to hide the preview affordance.
|
|
127
127
|
*
|
|
128
|
+
* `locale` is the content locale selected in the editor. Keep it even
|
|
129
|
+
* when that translation is not advertised: preview is how an editor
|
|
130
|
+
* reviews an unchecked translation. The locale prefix is your public
|
|
131
|
+
* routes' rule, which this scaffold cannot know. This default assumes
|
|
132
|
+
* the content default locale is served without a prefix and every other
|
|
133
|
+
* locale under `/<locale>`; change it to match your routes. Never derive
|
|
134
|
+
* the prefix from the admin interface language.
|
|
135
|
+
*
|
|
128
136
|
* `doc.path` is the top-level slug (derived from `useAsPath`), not a
|
|
129
137
|
* field. Direct relations are auto-populated by the edit view (depth
|
|
130
138
|
* 1, picker projection) and appear under `doc.fields.<name>?.document`.
|
|
@@ -133,7 +141,7 @@ export const PagesAdmin: CollectionAdminConfig = defineAdmin(Pages, {
|
|
|
133
141
|
url: (doc, { locale }) => {
|
|
134
142
|
const path = Pages.buildDocumentPath?.(doc, { collectionPath: Pages.path }) ?? null
|
|
135
143
|
if (path == null) return null
|
|
136
|
-
const prefix = locale && locale !== i18n.
|
|
144
|
+
const prefix = locale && locale !== i18n.content.defaultLocale ? `/${locale}` : ''
|
|
137
145
|
return `${prefix}${path}`
|
|
138
146
|
},
|
|
139
147
|
},
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/cli",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "6.
|
|
5
|
+
"version": "6.7.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "^7.0.2",
|
|
62
62
|
"unified": "^11.0.5",
|
|
63
63
|
"vitest": "^5.0.1",
|
|
64
|
-
"@byline/core": "6.
|
|
64
|
+
"@byline/core": "6.7.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public",
|