@rr0/cms 0.1.23 → 0.1.24

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/RR0Build.js CHANGED
@@ -6,7 +6,7 @@ import { GooglePlaceService, PlaceReplacerFactory } from "./place/index.js";
6
6
  import { OrganizationFactory, OrganizationService } from "./org/index.js";
7
7
  import { RR0ContextImpl } from "./RR0Context.js";
8
8
  import { HtmlTable } from "./util/index.js";
9
- import { AngularExpressionReplaceCommand, ClassDomReplaceCommand, CopyStep, DomReplaceCommand, HtAccessToNetlifyConfigReplaceCommand, Ssg, SsiEchoVarReplaceCommand, SsiIfReplaceCommand, SsiIncludeReplaceCommand, SsiLastModifiedReplaceCommand, SsiSetVarReplaceCommand, StringEchoVarReplaceCommand } from "ssg-api";
9
+ import { AngularExpressionReplaceCommand, ClassDomReplaceCommand, CopyStep, DomReplaceCommand, HtAccessToNetlifyConfigReplaceCommand, HtmlFileContents, Ssg, SsiEchoVarReplaceCommand, SsiIfReplaceCommand, SsiIncludeReplaceCommand, SsiLastModifiedReplaceCommand, SsiSetVarReplaceCommand, StringEchoVarReplaceCommand } from "ssg-api";
10
10
  import { LanguageReplaceCommand } from "./lang/index.js";
11
11
  import { AuthorReplaceCommand, PeopleDirectoryStepFactory, PeopleFactory, PeopleReplacerFactory, PeopleService, WitnessReplacerFactory } from "./people";
12
12
  import { PersistentSourceRegistry, SourceFileCounter, SourceIndexStep, SourceRenderer, SourceReplacer, SourceReplacerFactory } from "./source";
@@ -31,7 +31,9 @@ import { writeFile } from "@javarome/fileutil";
31
31
  import { AllDataService, RR0EventFactory, TypedDataFactory } from "@rr0/data";
32
32
  const outputFunc = async (context, outFile) => {
33
33
  try {
34
- context.file.contents = context.file.serialize();
34
+ if (context.file instanceof HtmlFileContents) {
35
+ context.file.contents = context.file.serialize();
36
+ }
35
37
  context.log("Writing", outFile.name);
36
38
  await outFile.write();
37
39
  context.file.contents = outFile.contents;
@@ -1,17 +1,13 @@
1
1
  import { glob } from "glob";
2
2
  import { describe } from "@javarome/testscript";
3
- import { FileContents } from "@javarome/fileutil";
4
- import { CLI } from "./util/index.js";
5
3
  import { RR0Build } from "./RR0Build.js";
6
4
  import { testFilePath } from "./test";
7
5
  import * as process from "node:process";
8
6
  describe("Build", () => {
9
7
  console.time("ssg");
10
- let args = new CLI().getArgs();
11
- const configFile = args.config;
12
- if (configFile) {
13
- args = JSON.parse(FileContents.read(configFile).contents);
14
- }
8
+ const args = {
9
+ force: "true"
10
+ };
15
11
  const cliContents = args.contents;
16
12
  console.debug("contents", cliContents);
17
13
  const mandatoryRoots = ["people/*.html", "science/crypto/ufo/enquete/dossier/*.html"];
@@ -9,6 +9,15 @@ export class RR0ContextImpl extends SsgContextImpl {
9
9
  this.messages = messages;
10
10
  this.images = new Set();
11
11
  this.fileMap = new Map();
12
+ while (!this.messages) {
13
+ if (locale.length > 2) {
14
+ locale = locale.substring(0, 2); // Fallback to language without country specifics
15
+ }
16
+ else {
17
+ locale = "fr"; // Default language
18
+ }
19
+ this.messages = ssgMessages[locale];
20
+ }
12
21
  }
13
22
  read(filePath) {
14
23
  let file = this.fileMap.get(filePath);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { describe, expect, test } from "@javarome/testscript";
2
+ import { rr0TestUtil } from "./test";
3
+ import { ssgMessages } from "./lang";
4
+ describe("RROContextImpl", () => {
5
+ describe("constructor with locale", () => {
6
+ test("default locale", () => {
7
+ const context = rr0TestUtil.time.newHtmlContext("test.html", "");
8
+ expect(context.locale).toBe("fr");
9
+ });
10
+ test("supported locale", () => {
11
+ const context = rr0TestUtil.time.newHtmlContext("test.html", "", "en");
12
+ expect(context.locale).toBe("en");
13
+ });
14
+ test("locale fallback to lang only", () => {
15
+ const context = rr0TestUtil.time.newHtmlContext("test.html", "", "en-US");
16
+ expect(context.messages).toEqual(ssgMessages["en"]);
17
+ });
18
+ test("locale fallback to default", () => {
19
+ const context = rr0TestUtil.time.newHtmlContext("test.html", "", "xx");
20
+ expect(context.messages).toEqual(ssgMessages["fr"]);
21
+ });
22
+ });
23
+ });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rr0/cms",
3
3
  "type": "module",
4
4
  "author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
5
- "version": "0.1.23",
5
+ "version": "0.1.24",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -23,14 +23,14 @@
23
23
  "build": "rm -Rf dist && tsc --project tsconfig.prod.json",
24
24
  "prepublishOnly": "npm run build",
25
25
  "test": "testscript",
26
- "test-one": "rm -Rf out && tsx src/RR0Build.test.ts",
26
+ "test-one": "rm -Rf out && tsx src/RR0Context.test.ts",
27
27
  "test-ci": "rm -Rf out && testscript"
28
28
  },
29
29
  "dependencies": {
30
30
  "@googlemaps/google-maps-services-js": "^3.4.0",
31
31
  "@rr0/common": "^1.1.3",
32
32
  "@rr0/lang": "^0.1.12",
33
- "@rr0/time": "^0.8.4",
33
+ "@rr0/time": "^0.8.5",
34
34
  "@rr0/place": "^0.3.2",
35
35
  "@rr0/data": "^0.1.2",
36
36
  "@javarome/fileutil": "^0.3.6",