@growi/pluginkit 1.1.1 → 1.2.0-next.d92d1aa0318d5fdc7fe811d2d94d2cd9e881ec33
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/LICENSE +1 -1
- package/dist/model/growi-plugin-validation-error.cjs.map +1 -1
- package/dist/model/growi-plugin-validation-error.js.map +1 -1
- package/dist/v4/client/utils/growi-facade/growi-react.cjs.map +1 -1
- package/dist/v4/client/utils/growi-facade/growi-react.js.map +1 -1
- package/dist/v4/interfaces/template.cjs.map +1 -1
- package/dist/v4/interfaces/template.js.map +1 -1
- package/dist/v4/server/utils/common/import-package-json.cjs +1 -1
- package/dist/v4/server/utils/common/import-package-json.cjs.map +1 -1
- package/dist/v4/server/utils/common/import-package-json.js +2 -2
- package/dist/v4/server/utils/common/import-package-json.js.map +1 -1
- package/dist/v4/server/utils/common/validate-growi-plugin-directive.cjs +1 -1
- package/dist/v4/server/utils/common/validate-growi-plugin-directive.cjs.map +1 -1
- package/dist/v4/server/utils/common/validate-growi-plugin-directive.js +24 -8
- package/dist/v4/server/utils/common/validate-growi-plugin-directive.js.map +1 -1
- package/dist/v4/server/utils/template/get-markdown.cjs +1 -1
- package/dist/v4/server/utils/template/get-markdown.cjs.map +1 -1
- package/dist/v4/server/utils/template/get-markdown.js +2 -2
- package/dist/v4/server/utils/template/get-markdown.js.map +1 -1
- package/dist/v4/server/utils/template/get-status.cjs +1 -1
- package/dist/v4/server/utils/template/get-status.cjs.map +1 -1
- package/dist/v4/server/utils/template/get-status.js +3 -3
- package/dist/v4/server/utils/template/get-status.js.map +1 -1
- package/dist/v4/server/utils/template/scan.cjs +1 -1
- package/dist/v4/server/utils/template/scan.cjs.map +1 -1
- package/dist/v4/server/utils/template/scan.js +16 -10
- package/dist/v4/server/utils/template/scan.js.map +1 -1
- package/dist/v4/server/utils/template/validate-all-locales.cjs +1 -1
- package/dist/v4/server/utils/template/validate-all-locales.cjs.map +1 -1
- package/dist/v4/server/utils/template/validate-all-locales.js +18 -12
- package/dist/v4/server/utils/template/validate-all-locales.js.map +1 -1
- package/dist/v4/server/utils/template/validate-growi-plugin-directive.cjs.map +1 -1
- package/dist/v4/server/utils/template/validate-growi-plugin-directive.js.map +1 -1
- package/dist/v4/server/utils/theme/validate-growi-plugin-directive.cjs +1 -1
- package/dist/v4/server/utils/theme/validate-growi-plugin-directive.cjs.map +1 -1
- package/dist/v4/server/utils/theme/validate-growi-plugin-directive.js +7 -7
- package/dist/v4/server/utils/theme/validate-growi-plugin-directive.js.map +1 -1
- package/dist/v4/utils/template.cjs.map +1 -1
- package/dist/v4/utils/template.d.ts +1 -1
- package/dist/v4/utils/template.js.map +1 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-plugin-validation-error.cjs","sources":["../../src/model/growi-plugin-validation-error.ts"],"sourcesContent":["import ExtensibleCustomError from 'extensible-custom-error';\n\nimport type { GrowiPluginValidationData } from './growi-plugin-validation-data';\n\
|
|
1
|
+
{"version":3,"file":"growi-plugin-validation-error.cjs","sources":["../../src/model/growi-plugin-validation-error.ts"],"sourcesContent":["import ExtensibleCustomError from 'extensible-custom-error';\n\nimport type { GrowiPluginValidationData } from './growi-plugin-validation-data';\n\nexport class GrowiPluginValidationError<\n E extends\n Partial<GrowiPluginValidationData> = Partial<GrowiPluginValidationData>,\n> extends ExtensibleCustomError {\n data?: E;\n\n constructor(message: string, data?: E) {\n super(message);\n this.data = data;\n }\n}\n"],"names":["GrowiPluginValidationError","ExtensibleCustomError","message","data","__publicField"],"mappings":"+RAIO,MAAMA,UAGHC,CAAsB,CAG9B,YAAYC,EAAiBC,EAAU,CACrC,MAAMD,CAAO,EAHfE,EAAA,aAIE,KAAK,KAAOD,CAAA,CAEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-plugin-validation-error.js","sources":["../../src/model/growi-plugin-validation-error.ts"],"sourcesContent":["import ExtensibleCustomError from 'extensible-custom-error';\n\nimport type { GrowiPluginValidationData } from './growi-plugin-validation-data';\n\
|
|
1
|
+
{"version":3,"file":"growi-plugin-validation-error.js","sources":["../../src/model/growi-plugin-validation-error.ts"],"sourcesContent":["import ExtensibleCustomError from 'extensible-custom-error';\n\nimport type { GrowiPluginValidationData } from './growi-plugin-validation-data';\n\nexport class GrowiPluginValidationError<\n E extends\n Partial<GrowiPluginValidationData> = Partial<GrowiPluginValidationData>,\n> extends ExtensibleCustomError {\n data?: E;\n\n constructor(message: string, data?: E) {\n super(message);\n this.data = data;\n }\n}\n"],"names":["GrowiPluginValidationError","ExtensibleCustomError","message","data","__publicField"],"mappings":";;;;AAIO,MAAMA,UAGHC,EAAsB;AAAA,EAG9B,YAAYC,GAAiBC,GAAU;AACrC,UAAMD,CAAO;AAHf,IAAAE,EAAA;AAIE,SAAK,OAAOD;AAAA,EAAA;AAEhB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-react.cjs","sources":["../../../../../src/v4/client/utils/growi-facade/growi-react.ts"],"sourcesContent":["import type React from 'react';\
|
|
1
|
+
{"version":3,"file":"growi-react.cjs","sources":["../../../../../src/v4/client/utils/growi-facade/growi-react.ts"],"sourcesContent":["import type React from 'react';\nimport type { GrowiFacade } from '@growi/core';\n\ndeclare global {\n interface Window {\n growiFacade: GrowiFacade;\n }\n}\n\n/**\n * Retrieves the React instance that this package should use.\n *\n * - **Production Mode**: Returns the React instance from `window.growiFacade.react`\n * to ensure a single shared React instance across the app.\n * - **Development Mode**: Returns the React instance passed as an argument,\n * which allows local development and hot reload without issues.\n *\n * @param react - The React instance to use during development\n * @returns A React instance to be used in the current environment\n *\n * @remarks\n * Using multiple React instances in a single app can cause serious issues,\n * especially with features like Hooks, which rely on a consistent internal state.\n * This function ensures that only one React instance is used in production\n * to avoid such problems.\n */\nexport const growiReact = (react: typeof React): typeof React => {\n if (process.env.NODE_ENV === 'production') {\n return window.growiFacade.react as typeof React;\n }\n return react as typeof React;\n};\n"],"names":["growiReact","react"],"mappings":"gFA0Ba,MAAAA,EAAcC,GACrB,QAAQ,IAAI,WAAa,aACpB,OAAO,YAAY,MAErBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-react.js","sources":["../../../../../src/v4/client/utils/growi-facade/growi-react.ts"],"sourcesContent":["import type React from 'react';\
|
|
1
|
+
{"version":3,"file":"growi-react.js","sources":["../../../../../src/v4/client/utils/growi-facade/growi-react.ts"],"sourcesContent":["import type React from 'react';\nimport type { GrowiFacade } from '@growi/core';\n\ndeclare global {\n interface Window {\n growiFacade: GrowiFacade;\n }\n}\n\n/**\n * Retrieves the React instance that this package should use.\n *\n * - **Production Mode**: Returns the React instance from `window.growiFacade.react`\n * to ensure a single shared React instance across the app.\n * - **Development Mode**: Returns the React instance passed as an argument,\n * which allows local development and hot reload without issues.\n *\n * @param react - The React instance to use during development\n * @returns A React instance to be used in the current environment\n *\n * @remarks\n * Using multiple React instances in a single app can cause serious issues,\n * especially with features like Hooks, which rely on a consistent internal state.\n * This function ensures that only one React instance is used in production\n * to avoid such problems.\n */\nexport const growiReact = (react: typeof React): typeof React => {\n if (process.env.NODE_ENV === 'production') {\n return window.growiFacade.react as typeof React;\n }\n return react as typeof React;\n};\n"],"names":["growiReact","react"],"mappings":"AA0Ba,MAAAA,IAAa,CAACC,MACrB,QAAQ,IAAI,aAAa,eACpB,OAAO,YAAY,QAErBA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.cjs","sources":["../../../src/v4/interfaces/template.ts"],"sourcesContent":["export type TemplateStatusBasis = {\n id: string
|
|
1
|
+
{"version":3,"file":"template.cjs","sources":["../../../src/v4/interfaces/template.ts"],"sourcesContent":["export type TemplateStatusBasis = {\n id: string;\n locale: string;\n pluginId?: string;\n};\nexport type TemplateStatusValid = TemplateStatusBasis & {\n isValid: true;\n isDefault: boolean;\n title: string;\n desc?: string;\n};\nexport type TemplateStatusInvalid = TemplateStatusBasis & {\n isValid: false;\n invalidReason: string;\n};\nexport type TemplateStatus = TemplateStatusValid | TemplateStatusInvalid;\n\nexport function isTemplateStatusValid(\n status: TemplateStatus,\n): status is TemplateStatusValid {\n return status.isValid;\n}\n\nexport type TemplateSummary = {\n default: TemplateStatusValid;\n [locale: string]: TemplateStatus;\n};\n"],"names":["isTemplateStatusValid","status"],"mappings":"gFAiBO,SAASA,EACdC,EAC+B,CAC/B,OAAOA,EAAO,OAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sources":["../../../src/v4/interfaces/template.ts"],"sourcesContent":["export type TemplateStatusBasis = {\n id: string
|
|
1
|
+
{"version":3,"file":"template.js","sources":["../../../src/v4/interfaces/template.ts"],"sourcesContent":["export type TemplateStatusBasis = {\n id: string;\n locale: string;\n pluginId?: string;\n};\nexport type TemplateStatusValid = TemplateStatusBasis & {\n isValid: true;\n isDefault: boolean;\n title: string;\n desc?: string;\n};\nexport type TemplateStatusInvalid = TemplateStatusBasis & {\n isValid: false;\n invalidReason: string;\n};\nexport type TemplateStatus = TemplateStatusValid | TemplateStatusInvalid;\n\nexport function isTemplateStatusValid(\n status: TemplateStatus,\n): status is TemplateStatusValid {\n return status.isValid;\n}\n\nexport type TemplateSummary = {\n default: TemplateStatusValid;\n [locale: string]: TemplateStatus;\n};\n"],"names":["isTemplateStatusValid","status"],"mappings":"AAiBO,SAASA,EACdC,GAC+B;AAC/B,SAAOA,EAAO;AAChB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("fs"),t=require("path"),a=e=>{const r=t.resolve(e,"package.json");return JSON.parse(o.readFileSync(r,"utf-8"))};exports.importPackageJson=a;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),t=require("node:path"),a=e=>{const r=t.resolve(e,"package.json");return JSON.parse(o.readFileSync(r,"utf-8"))};exports.importPackageJson=a;
|
|
2
2
|
//# sourceMappingURL=import-package-json.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-package-json.cjs","sources":["../../../../../src/v4/server/utils/common/import-package-json.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport path from 'path';\n\nimport type { GrowiPluginPackageData } from '../../../../model';\n\nexport const importPackageJson = (projectDirRoot: string): GrowiPluginPackageData => {\n const packageJsonUrl = path.resolve(projectDirRoot, 'package.json');\n return JSON.parse(readFileSync(packageJsonUrl, 'utf-8'));\n};\n"],"names":["importPackageJson","projectDirRoot","packageJsonUrl","path","readFileSync"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import-package-json.cjs","sources":["../../../../../src/v4/server/utils/common/import-package-json.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { GrowiPluginPackageData } from '../../../../model';\n\nexport const importPackageJson = (\n projectDirRoot: string,\n): GrowiPluginPackageData => {\n const packageJsonUrl = path.resolve(projectDirRoot, 'package.json');\n return JSON.parse(readFileSync(packageJsonUrl, 'utf-8'));\n};\n"],"names":["importPackageJson","projectDirRoot","packageJsonUrl","path","readFileSync"],"mappings":"kIAKaA,EACXC,GAC2B,CAC3B,MAAMC,EAAiBC,EAAK,QAAQF,EAAgB,cAAc,EAClE,OAAO,KAAK,MAAMG,EAAa,aAAAF,EAAgB,OAAO,CAAC,CACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-package-json.js","sources":["../../../../../src/v4/server/utils/common/import-package-json.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport path from 'path';\n\nimport type { GrowiPluginPackageData } from '../../../../model';\n\nexport const importPackageJson = (projectDirRoot: string): GrowiPluginPackageData => {\n const packageJsonUrl = path.resolve(projectDirRoot, 'package.json');\n return JSON.parse(readFileSync(packageJsonUrl, 'utf-8'));\n};\n"],"names":["importPackageJson","projectDirRoot","packageJsonUrl","path","readFileSync"],"mappings":";;AAKa,MAAAA,IAAoB,
|
|
1
|
+
{"version":3,"file":"import-package-json.js","sources":["../../../../../src/v4/server/utils/common/import-package-json.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { GrowiPluginPackageData } from '../../../../model';\n\nexport const importPackageJson = (\n projectDirRoot: string,\n): GrowiPluginPackageData => {\n const packageJsonUrl = path.resolve(projectDirRoot, 'package.json');\n return JSON.parse(readFileSync(packageJsonUrl, 'utf-8'));\n};\n"],"names":["importPackageJson","projectDirRoot","packageJsonUrl","path","readFileSync"],"mappings":";;AAKa,MAAAA,IAAoB,CAC/BC,MAC2B;AAC3B,QAAMC,IAAiBC,EAAK,QAAQF,GAAgB,cAAc;AAClE,SAAO,KAAK,MAAMG,EAAaF,GAAgB,OAAO,CAAC;AACzD;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../../model/growi-plugin-validation-error.cjs"),l=require("./import-package-json.cjs"),c=(a,o)=>{const s=l.importPackageJson(a),{growiPlugin:e}=s,i={projectDirRoot:a,schemaVersion:NaN,growiPlugin:e};if(e==null)throw new r.GrowiPluginValidationError("The package.json does not have 'growiPlugin' directive.",i);const n=Number(e.schemaVersion);if(i.schemaVersion=n,Number.isNaN(n)||n<4)throw new r.GrowiPluginValidationError("The growiPlugin directive must have a valid 'schemaVersion' directive.",i);const t=e.types;if(i.actualPluginTypes=t,t==null)throw new r.GrowiPluginValidationError("The growiPlugin directive does not have 'types' directive.",i);if(o!=null&&(i.expectedPluginType=o,!t.includes(o)))throw new r.GrowiPluginValidationError("The growiPlugin directive does not have expected plugin type in 'types' directive.",i);return i};exports.validateGrowiDirective=c;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../../model/growi-plugin-validation-error.cjs"),l=require("./import-package-json.cjs"),c=(a,o)=>{const s=l.importPackageJson(a),{growiPlugin:e}=s,i={projectDirRoot:a,schemaVersion:Number.NaN,growiPlugin:e};if(e==null)throw new r.GrowiPluginValidationError("The package.json does not have 'growiPlugin' directive.",i);const n=Number(e.schemaVersion);if(i.schemaVersion=n,Number.isNaN(n)||n<4)throw new r.GrowiPluginValidationError("The growiPlugin directive must have a valid 'schemaVersion' directive.",i);const t=e.types;if(i.actualPluginTypes=t,t==null)throw new r.GrowiPluginValidationError("The growiPlugin directive does not have 'types' directive.",i);if(o!=null&&(i.expectedPluginType=o,!t.includes(o)))throw new r.GrowiPluginValidationError("The growiPlugin directive does not have expected plugin type in 'types' directive.",i);return i};exports.validateGrowiDirective=c;
|
|
2
2
|
//# sourceMappingURL=validate-growi-plugin-directive.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiPluginType } from '@growi/core';\n\nimport {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiPluginType } from '@growi/core';\n\nimport {\n type GrowiPluginValidationData,\n GrowiPluginValidationError,\n} from '../../../../model';\nimport { importPackageJson } from './import-package-json';\n\nexport const validateGrowiDirective = (\n projectDirRoot: string,\n expectedPluginType?: GrowiPluginType,\n): GrowiPluginValidationData => {\n const pkg = importPackageJson(projectDirRoot);\n\n const { growiPlugin } = pkg;\n\n const data: GrowiPluginValidationData = {\n projectDirRoot,\n schemaVersion: Number.NaN,\n growiPlugin,\n };\n\n if (growiPlugin == null) {\n throw new GrowiPluginValidationError(\n \"The package.json does not have 'growiPlugin' directive.\",\n data,\n );\n }\n\n // schema version checking\n const schemaVersion = Number(growiPlugin.schemaVersion);\n data.schemaVersion = schemaVersion;\n if (Number.isNaN(schemaVersion) || schemaVersion < 4) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive must have a valid 'schemaVersion' directive.\",\n data,\n );\n }\n\n const types: GrowiPluginType[] = growiPlugin.types;\n data.actualPluginTypes = types;\n if (types == null) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive does not have 'types' directive.\",\n data,\n );\n }\n\n // type checking\n if (expectedPluginType != null) {\n data.expectedPluginType = expectedPluginType;\n\n if (!types.includes(expectedPluginType)) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive does not have expected plugin type in 'types' directive.\",\n data,\n );\n }\n }\n\n return data;\n};\n"],"names":["validateGrowiDirective","projectDirRoot","expectedPluginType","pkg","importPackageJson","growiPlugin","data","GrowiPluginValidationError","schemaVersion","types"],"mappings":"8LAQaA,EAAyB,CACpCC,EACAC,IAC8B,CACxB,MAAAC,EAAMC,oBAAkBH,CAAc,EAEtC,CAAE,YAAAI,GAAgBF,EAElBG,EAAkC,CACtC,eAAAL,EACA,cAAe,OAAO,IACtB,YAAAI,CACF,EAEA,GAAIA,GAAe,KACjB,MAAM,IAAIE,EAAA,2BACR,0DACAD,CACF,EAII,MAAAE,EAAgB,OAAOH,EAAY,aAAa,EAEtD,GADAC,EAAK,cAAgBE,EACjB,OAAO,MAAMA,CAAa,GAAKA,EAAgB,EACjD,MAAM,IAAID,EAAA,2BACR,yEACAD,CACF,EAGF,MAAMG,EAA2BJ,EAAY,MAE7C,GADAC,EAAK,kBAAoBG,EACrBA,GAAS,KACX,MAAM,IAAIF,EAAA,2BACR,6DACAD,CACF,EAIF,GAAIJ,GAAsB,OACxBI,EAAK,mBAAqBJ,EAEtB,CAACO,EAAM,SAASP,CAAkB,GACpC,MAAM,IAAIK,EAAA,2BACR,qFACAD,CACF,EAIG,OAAAA,CACT"}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
import { GrowiPluginValidationError as
|
|
1
|
+
import { GrowiPluginValidationError as r } from "../../../../model/growi-plugin-validation-error.js";
|
|
2
2
|
import { importPackageJson as c } from "./import-package-json.js";
|
|
3
|
-
const u = (s,
|
|
4
|
-
const a = c(s), { growiPlugin: i } = a, e = {
|
|
3
|
+
const u = (s, o) => {
|
|
4
|
+
const a = c(s), { growiPlugin: i } = a, e = {
|
|
5
|
+
projectDirRoot: s,
|
|
6
|
+
schemaVersion: Number.NaN,
|
|
7
|
+
growiPlugin: i
|
|
8
|
+
};
|
|
5
9
|
if (i == null)
|
|
6
|
-
throw new
|
|
10
|
+
throw new r(
|
|
11
|
+
"The package.json does not have 'growiPlugin' directive.",
|
|
12
|
+
e
|
|
13
|
+
);
|
|
7
14
|
const n = Number(i.schemaVersion);
|
|
8
15
|
if (e.schemaVersion = n, Number.isNaN(n) || n < 4)
|
|
9
|
-
throw new
|
|
16
|
+
throw new r(
|
|
17
|
+
"The growiPlugin directive must have a valid 'schemaVersion' directive.",
|
|
18
|
+
e
|
|
19
|
+
);
|
|
10
20
|
const t = i.types;
|
|
11
21
|
if (e.actualPluginTypes = t, t == null)
|
|
12
|
-
throw new
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
throw new r(
|
|
23
|
+
"The growiPlugin directive does not have 'types' directive.",
|
|
24
|
+
e
|
|
25
|
+
);
|
|
26
|
+
if (o != null && (e.expectedPluginType = o, !t.includes(o)))
|
|
27
|
+
throw new r(
|
|
28
|
+
"The growiPlugin directive does not have expected plugin type in 'types' directive.",
|
|
29
|
+
e
|
|
30
|
+
);
|
|
15
31
|
return e;
|
|
16
32
|
};
|
|
17
33
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiPluginType } from '@growi/core';\n\nimport {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiPluginType } from '@growi/core';\n\nimport {\n type GrowiPluginValidationData,\n GrowiPluginValidationError,\n} from '../../../../model';\nimport { importPackageJson } from './import-package-json';\n\nexport const validateGrowiDirective = (\n projectDirRoot: string,\n expectedPluginType?: GrowiPluginType,\n): GrowiPluginValidationData => {\n const pkg = importPackageJson(projectDirRoot);\n\n const { growiPlugin } = pkg;\n\n const data: GrowiPluginValidationData = {\n projectDirRoot,\n schemaVersion: Number.NaN,\n growiPlugin,\n };\n\n if (growiPlugin == null) {\n throw new GrowiPluginValidationError(\n \"The package.json does not have 'growiPlugin' directive.\",\n data,\n );\n }\n\n // schema version checking\n const schemaVersion = Number(growiPlugin.schemaVersion);\n data.schemaVersion = schemaVersion;\n if (Number.isNaN(schemaVersion) || schemaVersion < 4) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive must have a valid 'schemaVersion' directive.\",\n data,\n );\n }\n\n const types: GrowiPluginType[] = growiPlugin.types;\n data.actualPluginTypes = types;\n if (types == null) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive does not have 'types' directive.\",\n data,\n );\n }\n\n // type checking\n if (expectedPluginType != null) {\n data.expectedPluginType = expectedPluginType;\n\n if (!types.includes(expectedPluginType)) {\n throw new GrowiPluginValidationError(\n \"The growiPlugin directive does not have expected plugin type in 'types' directive.\",\n data,\n );\n }\n }\n\n return data;\n};\n"],"names":["validateGrowiDirective","projectDirRoot","expectedPluginType","pkg","importPackageJson","growiPlugin","data","GrowiPluginValidationError","schemaVersion","types"],"mappings":";;AAQa,MAAAA,IAAyB,CACpCC,GACAC,MAC8B;AACxB,QAAAC,IAAMC,EAAkBH,CAAc,GAEtC,EAAE,aAAAI,MAAgBF,GAElBG,IAAkC;AAAA,IACtC,gBAAAL;AAAA,IACA,eAAe,OAAO;AAAA,IACtB,aAAAI;AAAA,EACF;AAEA,MAAIA,KAAe;AACjB,UAAM,IAAIE;AAAA,MACR;AAAA,MACAD;AAAA,IACF;AAII,QAAAE,IAAgB,OAAOH,EAAY,aAAa;AAEtD,MADAC,EAAK,gBAAgBE,GACjB,OAAO,MAAMA,CAAa,KAAKA,IAAgB;AACjD,UAAM,IAAID;AAAA,MACR;AAAA,MACAD;AAAA,IACF;AAGF,QAAMG,IAA2BJ,EAAY;AAE7C,MADAC,EAAK,oBAAoBG,GACrBA,KAAS;AACX,UAAM,IAAIF;AAAA,MACR;AAAA,MACAD;AAAA,IACF;AAIF,MAAIJ,KAAsB,SACxBI,EAAK,qBAAqBJ,GAEtB,CAACO,EAAM,SAASP,CAAkB;AACpC,UAAM,IAAIK;AAAA,MACR;AAAA,MACAD;AAAA,IACF;AAIG,SAAAA;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),e=require("path"),c=require("./get-status.cjs"),d=async(r,o,s)=>{const t=e.resolve(r,"dist",o,s),{isTemplateExists:n}=await c.getStatus(t);if(!n)throw new Error("'template.md does not exist.");const a=e.resolve(t,"template.md");return i.readFileSync(a,{encoding:"utf-8"})};exports.getMarkdown=d;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),e=require("node:path"),c=require("./get-status.cjs"),d=async(r,o,s)=>{const t=e.resolve(r,"dist",o,s),{isTemplateExists:n}=await c.getStatus(t);if(!n)throw new Error("'template.md does not exist.");const a=e.resolve(t,"template.md");return i.readFileSync(a,{encoding:"utf-8"})};exports.getMarkdown=d;
|
|
2
2
|
//# sourceMappingURL=get-markdown.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-markdown.cjs","sources":["../../../../../src/v4/server/utils/template/get-markdown.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { getStatus } from './get-status';\n\
|
|
1
|
+
{"version":3,"file":"get-markdown.cjs","sources":["../../../../../src/v4/server/utils/template/get-markdown.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { getStatus } from './get-status';\n\nexport const getMarkdown = async (\n projectDirRoot: string,\n templateId: string,\n locale: string,\n): Promise<string> => {\n const tplDir = path.resolve(projectDirRoot, 'dist', templateId, locale);\n\n const { isTemplateExists } = await getStatus(tplDir);\n\n if (!isTemplateExists) throw new Error(\"'template.md does not exist.\");\n\n const markdownPath = path.resolve(tplDir, 'template.md');\n return fs.readFileSync(markdownPath, { encoding: 'utf-8' });\n};\n"],"names":["getMarkdown","projectDirRoot","templateId","locale","tplDir","path","isTemplateExists","getStatus","markdownPath","fs"],"mappings":"gKAKaA,EAAc,MACzBC,EACAC,EACAC,IACoB,CACpB,MAAMC,EAASC,EAAK,QAAQJ,EAAgB,OAAQC,EAAYC,CAAM,EAEhE,CAAE,iBAAAG,CAAA,EAAqB,MAAMC,EAAAA,UAAUH,CAAM,EAEnD,GAAI,CAACE,EAAwB,MAAA,IAAI,MAAM,8BAA8B,EAErE,MAAME,EAAeH,EAAK,QAAQD,EAAQ,aAAa,EACvD,OAAOK,EAAG,aAAaD,EAAc,CAAE,SAAU,QAAS,CAC5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-markdown.js","sources":["../../../../../src/v4/server/utils/template/get-markdown.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { getStatus } from './get-status';\n\
|
|
1
|
+
{"version":3,"file":"get-markdown.js","sources":["../../../../../src/v4/server/utils/template/get-markdown.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { getStatus } from './get-status';\n\nexport const getMarkdown = async (\n projectDirRoot: string,\n templateId: string,\n locale: string,\n): Promise<string> => {\n const tplDir = path.resolve(projectDirRoot, 'dist', templateId, locale);\n\n const { isTemplateExists } = await getStatus(tplDir);\n\n if (!isTemplateExists) throw new Error(\"'template.md does not exist.\");\n\n const markdownPath = path.resolve(tplDir, 'template.md');\n return fs.readFileSync(markdownPath, { encoding: 'utf-8' });\n};\n"],"names":["getMarkdown","projectDirRoot","templateId","locale","tplDir","path","isTemplateExists","getStatus","markdownPath","fs"],"mappings":";;;AAKO,MAAMA,IAAc,OACzBC,GACAC,GACAC,MACoB;AACpB,QAAMC,IAASC,EAAK,QAAQJ,GAAgB,QAAQC,GAAYC,CAAM,GAEhE,EAAE,kBAAAG,EAAA,IAAqB,MAAMC,EAAUH,CAAM;AAEnD,MAAI,CAACE,EAAwB,OAAA,IAAI,MAAM,8BAA8B;AAErE,QAAME,IAAeH,EAAK,QAAQD,GAAQ,aAAa;AACvD,SAAOK,EAAG,aAAaD,GAAc,EAAE,UAAU,SAAS;AAC5D;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("fs"),a=require("path"),c=require("util"),s=c.promisify(o.stat);async function l(t){const r=a.resolve(t,"template.md"),i=(await s(r)).isFile(),e=a.resolve(t,"meta.json"),n=(await s(e)).isFile();return{isTemplateExists:i,meta:n?JSON.parse(o.readFileSync(e,"utf-8")):void 0}}exports.getStatus=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),a=require("node:path"),c=require("node:util"),s=c.promisify(o.stat);async function l(t){const r=a.resolve(t,"template.md"),i=(await s(r)).isFile(),e=a.resolve(t,"meta.json"),n=(await s(e)).isFile();return{isTemplateExists:i,meta:n?JSON.parse(o.readFileSync(e,"utf-8")):void 0}}exports.getStatus=l;
|
|
2
2
|
//# sourceMappingURL=get-status.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-status.cjs","sources":["../../../../../src/v4/server/utils/template/get-status.ts"],"sourcesContent":["import fs, { readFileSync } from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\n\
|
|
1
|
+
{"version":3,"file":"get-status.cjs","sources":["../../../../../src/v4/server/utils/template/get-status.ts"],"sourcesContent":["import fs, { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\n\nconst statAsync = promisify(fs.stat);\n\ntype TemplateDirStatus = {\n isTemplateExists: boolean;\n meta?: { [key: string]: string };\n};\n\nexport async function getStatus(tplDir: string): Promise<TemplateDirStatus> {\n const markdownPath = path.resolve(tplDir, 'template.md');\n const statForMarkdown = await statAsync(markdownPath);\n const isTemplateExists = statForMarkdown.isFile();\n\n const metaDataPath = path.resolve(tplDir, 'meta.json');\n const statForMetaDataFile = await statAsync(metaDataPath);\n const isMetaDataFileExists = statForMetaDataFile.isFile();\n\n const result: TemplateDirStatus = {\n isTemplateExists,\n meta: isMetaDataFileExists\n ? JSON.parse(readFileSync(metaDataPath, 'utf-8'))\n : undefined,\n };\n\n return result;\n}\n"],"names":["statAsync","promisify","fs","getStatus","tplDir","markdownPath","path","isTemplateExists","metaDataPath","isMetaDataFileExists","readFileSync"],"mappings":"yJAIMA,EAAYC,EAAAA,UAAUC,EAAG,IAAI,EAOnC,eAAsBC,EAAUC,EAA4C,CAC1E,MAAMC,EAAeC,EAAK,QAAQF,EAAQ,aAAa,EAEjDG,GADkB,MAAMP,EAAUK,CAAY,GACX,OAAO,EAE1CG,EAAeF,EAAK,QAAQF,EAAQ,WAAW,EAE/CK,GADsB,MAAMT,EAAUQ,CAAY,GACP,OAAO,EASjD,MAP2B,CAChC,iBAAAD,EACA,KAAME,EACF,KAAK,MAAMC,EAAAA,aAAaF,EAAc,OAAO,CAAC,EAC9C,MACN,CAGF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import n, { readFileSync as m } from "fs";
|
|
2
|
-
import s from "path";
|
|
3
|
-
import { promisify as c } from "util";
|
|
1
|
+
import n, { readFileSync as m } from "node:fs";
|
|
2
|
+
import s from "node:path";
|
|
3
|
+
import { promisify as c } from "node:util";
|
|
4
4
|
const o = c(n.stat);
|
|
5
5
|
async function w(t) {
|
|
6
6
|
const e = s.resolve(t, "template.md"), r = (await o(e)).isFile(), a = s.resolve(t, "meta.json"), i = (await o(a)).isFile();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-status.js","sources":["../../../../../src/v4/server/utils/template/get-status.ts"],"sourcesContent":["import fs, { readFileSync } from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\n\
|
|
1
|
+
{"version":3,"file":"get-status.js","sources":["../../../../../src/v4/server/utils/template/get-status.ts"],"sourcesContent":["import fs, { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\n\nconst statAsync = promisify(fs.stat);\n\ntype TemplateDirStatus = {\n isTemplateExists: boolean;\n meta?: { [key: string]: string };\n};\n\nexport async function getStatus(tplDir: string): Promise<TemplateDirStatus> {\n const markdownPath = path.resolve(tplDir, 'template.md');\n const statForMarkdown = await statAsync(markdownPath);\n const isTemplateExists = statForMarkdown.isFile();\n\n const metaDataPath = path.resolve(tplDir, 'meta.json');\n const statForMetaDataFile = await statAsync(metaDataPath);\n const isMetaDataFileExists = statForMetaDataFile.isFile();\n\n const result: TemplateDirStatus = {\n isTemplateExists,\n meta: isMetaDataFileExists\n ? JSON.parse(readFileSync(metaDataPath, 'utf-8'))\n : undefined,\n };\n\n return result;\n}\n"],"names":["statAsync","promisify","fs","getStatus","tplDir","markdownPath","path","isTemplateExists","metaDataPath","isMetaDataFileExists","readFileSync"],"mappings":";;;AAIA,MAAMA,IAAYC,EAAUC,EAAG,IAAI;AAOnC,eAAsBC,EAAUC,GAA4C;AAC1E,QAAMC,IAAeC,EAAK,QAAQF,GAAQ,aAAa,GAEjDG,KADkB,MAAMP,EAAUK,CAAY,GACX,OAAO,GAE1CG,IAAeF,EAAK,QAAQF,GAAQ,WAAW,GAE/CK,KADsB,MAAMT,EAAUQ,CAAY,GACP,OAAO;AASjD,SAP2B;AAAA,IAChC,kBAAAD;AAAA,IACA,MAAME,IACF,KAAK,MAAMC,EAAaF,GAAc,OAAO,CAAC,IAC9C;AAAA,EACN;AAGF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs"),o=require("path"),w=require("../../../interfaces/template.cjs"),T=require("./get-status.cjs"),v=require("./validate-growi-plugin-directive.cjs"),f=async(a,e,c,i)=>{const l=[],d=o.resolve(a,"dist",e);let u=!1;for await(const n of c.supportingLocales){const r=o.resolve(d,n);try{const t=await T.getStatus(r),{isTemplateExists:m,meta:s}=t;if(!m)throw new Error("'template.md does not exist.");if(s==null)throw new Error("'meta.md does not exist.");if((s==null?void 0:s.title)==null)throw new Error("'meta.md does not contain the title.");const g=!u;l.push({pluginId:i==null?void 0:i.pluginId,id:e,locale:n,isValid:!0,isDefault:g,title:s.title,desc:s.desc}),u=!0}catch(t){l.push({pluginId:i==null?void 0:i.pluginId,id:e,locale:n,isValid:!1,invalidReason:t.message})}}return console.debug(`Template directory (${a}) has scanned`,{status:l}),l},y=async(a,e)=>{const c=(e==null?void 0:e.data)??v.validateTemplatePluginGrowiDirective(a),i=[],l=o.resolve(a,"dist"),d=h.readdirSync(l);for await(const u of d){const n=(await f(a,u,c,{pluginId:e==null?void 0:e.pluginId})).filter(t=>e!=null&&e.returnsInvalidTemplates?!0:t.isValid),r=n.find(t=>"isDefault"in t&&t.isDefault);r==null||!w.isTemplateStatusValid(r)||i.push({default:r,...Object.fromEntries(n.map(t=>[t.locale,t]))})}return i};exports.scanAllTemplates=y;exports.scanTemplate=f;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("node:fs"),o=require("node:path"),w=require("../../../interfaces/template.cjs"),T=require("./get-status.cjs"),v=require("./validate-growi-plugin-directive.cjs"),f=async(a,e,c,i)=>{const l=[],d=o.resolve(a,"dist",e);let u=!1;for await(const n of c.supportingLocales){const r=o.resolve(d,n);try{const t=await T.getStatus(r),{isTemplateExists:m,meta:s}=t;if(!m)throw new Error("'template.md does not exist.");if(s==null)throw new Error("'meta.md does not exist.");if((s==null?void 0:s.title)==null)throw new Error("'meta.md does not contain the title.");const g=!u;l.push({pluginId:i==null?void 0:i.pluginId,id:e,locale:n,isValid:!0,isDefault:g,title:s.title,desc:s.desc}),u=!0}catch(t){l.push({pluginId:i==null?void 0:i.pluginId,id:e,locale:n,isValid:!1,invalidReason:t.message})}}return console.debug(`Template directory (${a}) has scanned`,{status:l}),l},y=async(a,e)=>{const c=(e==null?void 0:e.data)??v.validateTemplatePluginGrowiDirective(a),i=[],l=o.resolve(a,"dist"),d=h.readdirSync(l);for await(const u of d){const n=(await f(a,u,c,{pluginId:e==null?void 0:e.pluginId})).filter(t=>e!=null&&e.returnsInvalidTemplates?!0:t.isValid),r=n.find(t=>"isDefault"in t&&t.isDefault);r==null||!w.isTemplateStatusValid(r)||i.push({default:r,...Object.fromEntries(n.map(t=>[t.locale,t]))})}return i};exports.scanAllTemplates=y;exports.scanTemplate=f;
|
|
2
2
|
//# sourceMappingURL=scan.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.cjs","sources":["../../../../../src/v4/server/utils/template/scan.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { GrowiTemplatePluginValidationData } from '../../../../model';\nimport {
|
|
1
|
+
{"version":3,"file":"scan.cjs","sources":["../../../../../src/v4/server/utils/template/scan.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { GrowiTemplatePluginValidationData } from '../../../../model';\nimport {\n isTemplateStatusValid,\n type TemplateStatus,\n type TemplateSummary,\n} from '../../../interfaces';\nimport { getStatus } from './get-status';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\nexport const scanTemplate = async (\n projectDirRoot: string,\n templateId: string,\n data: GrowiTemplatePluginValidationData,\n opts?: {\n pluginId?: string;\n },\n): Promise<TemplateStatus[]> => {\n const status: TemplateStatus[] = [];\n\n const tplRootDirPath = path.resolve(projectDirRoot, 'dist', templateId);\n\n let isDefaultPushed = false;\n for await (const locale of data.supportingLocales) {\n const tplDir = path.resolve(tplRootDirPath, locale);\n\n try {\n const stats = await getStatus(tplDir);\n const { isTemplateExists, meta } = stats;\n\n if (!isTemplateExists) throw new Error(\"'template.md does not exist.\");\n if (meta == null) throw new Error(\"'meta.md does not exist.\");\n if (meta?.title == null)\n throw new Error(\"'meta.md does not contain the title.\");\n\n const isDefault = !isDefaultPushed;\n status.push({\n pluginId: opts?.pluginId,\n id: templateId,\n locale,\n isValid: true,\n isDefault,\n title: meta.title,\n desc: meta.desc,\n });\n isDefaultPushed = true;\n } catch (err) {\n status.push({\n pluginId: opts?.pluginId,\n id: templateId,\n locale,\n isValid: false,\n invalidReason: (err as Error).message,\n });\n }\n }\n\n // eslint-disable-next-line no-console\n console.debug(`Template directory (${projectDirRoot}) has scanned`, {\n status,\n });\n\n return status;\n};\n\nexport const scanAllTemplates = async (\n projectDirRoot: string,\n opts?: {\n data?: GrowiTemplatePluginValidationData;\n pluginId?: string;\n returnsInvalidTemplates?: boolean;\n },\n): Promise<TemplateSummary[]> => {\n const data =\n opts?.data ?? validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const summaries: TemplateSummary[] = [];\n\n const distDirPath = path.resolve(projectDirRoot, 'dist');\n const distDirFiles = fs.readdirSync(distDirPath);\n\n for await (const templateId of distDirFiles) {\n const status = (\n await scanTemplate(projectDirRoot, templateId, data, {\n pluginId: opts?.pluginId,\n })\n )\n // omit invalid templates if `returnsInvalidTemplates` is true\n .filter((s) => (opts?.returnsInvalidTemplates ? true : s.isValid));\n\n // determine default locale\n const defaultTemplateStatus = status.find(\n (s) => 'isDefault' in s && s.isDefault,\n );\n\n if (\n defaultTemplateStatus == null ||\n !isTemplateStatusValid(defaultTemplateStatus)\n ) {\n continue;\n }\n\n summaries.push({\n // for the 'default' key\n default: defaultTemplateStatus,\n // for each locale keys\n ...Object.fromEntries(\n status.map((templateStatus) => [templateStatus.locale, templateStatus]),\n ),\n });\n }\n\n return summaries;\n};\n"],"names":["scanTemplate","projectDirRoot","templateId","data","opts","status","tplRootDirPath","path","isDefaultPushed","locale","tplDir","stats","getStatus","isTemplateExists","meta","isDefault","err","scanAllTemplates","validateTemplatePluginGrowiDirective","summaries","distDirPath","distDirFiles","fs","s","defaultTemplateStatus","isTemplateStatusValid","templateStatus"],"mappings":"iQAYaA,EAAe,MAC1BC,EACAC,EACAC,EACAC,IAG8B,CAC9B,MAAMC,EAA2B,CAAC,EAE5BC,EAAiBC,EAAK,QAAQN,EAAgB,OAAQC,CAAU,EAEtE,IAAIM,EAAkB,GACL,gBAAAC,KAAUN,EAAK,kBAAmB,CACjD,MAAMO,EAASH,EAAK,QAAQD,EAAgBG,CAAM,EAE9C,GAAA,CACI,MAAAE,EAAQ,MAAMC,EAAA,UAAUF,CAAM,EAC9B,CAAE,iBAAAG,EAAkB,KAAAC,CAAA,EAASH,EAEnC,GAAI,CAACE,EAAwB,MAAA,IAAI,MAAM,8BAA8B,EACrE,GAAIC,GAAQ,KAAY,MAAA,IAAI,MAAM,0BAA0B,EAC5D,IAAIA,GAAA,YAAAA,EAAM,QAAS,KACX,MAAA,IAAI,MAAM,sCAAsC,EAExD,MAAMC,EAAY,CAACP,EACnBH,EAAO,KAAK,CACV,SAAUD,GAAA,YAAAA,EAAM,SAChB,GAAIF,EACJ,OAAAO,EACA,QAAS,GACT,UAAAM,EACA,MAAOD,EAAK,MACZ,KAAMA,EAAK,IAAA,CACZ,EACiBN,EAAA,SACXQ,EAAK,CACZX,EAAO,KAAK,CACV,SAAUD,GAAA,YAAAA,EAAM,SAChB,GAAIF,EACJ,OAAAO,EACA,QAAS,GACT,cAAgBO,EAAc,OAAA,CAC/B,CAAA,CACH,CAIM,eAAA,MAAM,uBAAuBf,CAAc,gBAAiB,CAClE,OAAAI,CAAA,CACD,EAEMA,CACT,EAEaY,EAAmB,MAC9BhB,EACAG,IAK+B,CAC/B,MAAMD,GACJC,GAAA,YAAAA,EAAM,OAAQc,EAAAA,qCAAqCjB,CAAc,EAE7DkB,EAA+B,CAAC,EAEhCC,EAAcb,EAAK,QAAQN,EAAgB,MAAM,EACjDoB,EAAeC,EAAG,YAAYF,CAAW,EAE/C,gBAAiBlB,KAAcmB,EAAc,CAC3C,MAAMhB,GACJ,MAAML,EAAaC,EAAgBC,EAAYC,EAAM,CACnD,SAAUC,GAAA,YAAAA,EAAM,QAAA,CACjB,GAGA,OAAQmB,GAAOnB,GAAA,MAAAA,EAAM,wBAA0B,GAAOmB,EAAE,OAAQ,EAG7DC,EAAwBnB,EAAO,KAClCkB,GAAM,cAAeA,GAAKA,EAAE,SAC/B,EAGEC,GAAyB,MACzB,CAACC,EAAA,sBAAsBD,CAAqB,GAK9CL,EAAU,KAAK,CAEb,QAASK,EAET,GAAG,OAAO,YACRnB,EAAO,IAAKqB,GAAmB,CAACA,EAAe,OAAQA,CAAc,CAAC,CAAA,CACxE,CACD,CAAA,CAGI,OAAAP,CACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import h from "fs";
|
|
2
|
-
import o from "path";
|
|
1
|
+
import h from "node:fs";
|
|
2
|
+
import o from "node:path";
|
|
3
3
|
import { isTemplateStatusValid as g } from "../../../interfaces/template.js";
|
|
4
4
|
import { getStatus as w } from "./get-status.js";
|
|
5
5
|
import { validateTemplatePluginGrowiDirective as T } from "./validate-growi-plugin-directive.js";
|
|
@@ -9,13 +9,11 @@ const v = async (a, e, u, i) => {
|
|
|
9
9
|
for await (const n of u.supportingLocales) {
|
|
10
10
|
const r = o.resolve(c, n);
|
|
11
11
|
try {
|
|
12
|
-
const t = await w(r), {
|
|
13
|
-
isTemplateExists: m,
|
|
14
|
-
meta: s
|
|
15
|
-
} = t;
|
|
12
|
+
const t = await w(r), { isTemplateExists: m, meta: s } = t;
|
|
16
13
|
if (!m) throw new Error("'template.md does not exist.");
|
|
17
14
|
if (s == null) throw new Error("'meta.md does not exist.");
|
|
18
|
-
if ((s == null ? void 0 : s.title) == null)
|
|
15
|
+
if ((s == null ? void 0 : s.title) == null)
|
|
16
|
+
throw new Error("'meta.md does not contain the title.");
|
|
19
17
|
const f = !d;
|
|
20
18
|
l.push({
|
|
21
19
|
pluginId: i == null ? void 0 : i.pluginId,
|
|
@@ -36,16 +34,24 @@ const v = async (a, e, u, i) => {
|
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
return console.debug(`Template directory (${a}) has scanned`, {
|
|
37
|
+
return console.debug(`Template directory (${a}) has scanned`, {
|
|
38
|
+
status: l
|
|
39
|
+
}), l;
|
|
40
40
|
}, P = async (a, e) => {
|
|
41
41
|
const u = (e == null ? void 0 : e.data) ?? T(a), i = [], l = o.resolve(a, "dist"), c = h.readdirSync(l);
|
|
42
42
|
for await (const d of c) {
|
|
43
|
-
const n = (await v(a, d, u, {
|
|
43
|
+
const n = (await v(a, d, u, {
|
|
44
|
+
pluginId: e == null ? void 0 : e.pluginId
|
|
45
|
+
})).filter((t) => e != null && e.returnsInvalidTemplates ? !0 : t.isValid), r = n.find(
|
|
46
|
+
(t) => "isDefault" in t && t.isDefault
|
|
47
|
+
);
|
|
44
48
|
r == null || !g(r) || i.push({
|
|
45
49
|
// for the 'default' key
|
|
46
50
|
default: r,
|
|
47
51
|
// for each locale keys
|
|
48
|
-
...Object.fromEntries(
|
|
52
|
+
...Object.fromEntries(
|
|
53
|
+
n.map((t) => [t.locale, t])
|
|
54
|
+
)
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
return i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sources":["../../../../../src/v4/server/utils/template/scan.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { GrowiTemplatePluginValidationData } from '../../../../model';\nimport {
|
|
1
|
+
{"version":3,"file":"scan.js","sources":["../../../../../src/v4/server/utils/template/scan.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { GrowiTemplatePluginValidationData } from '../../../../model';\nimport {\n isTemplateStatusValid,\n type TemplateStatus,\n type TemplateSummary,\n} from '../../../interfaces';\nimport { getStatus } from './get-status';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\nexport const scanTemplate = async (\n projectDirRoot: string,\n templateId: string,\n data: GrowiTemplatePluginValidationData,\n opts?: {\n pluginId?: string;\n },\n): Promise<TemplateStatus[]> => {\n const status: TemplateStatus[] = [];\n\n const tplRootDirPath = path.resolve(projectDirRoot, 'dist', templateId);\n\n let isDefaultPushed = false;\n for await (const locale of data.supportingLocales) {\n const tplDir = path.resolve(tplRootDirPath, locale);\n\n try {\n const stats = await getStatus(tplDir);\n const { isTemplateExists, meta } = stats;\n\n if (!isTemplateExists) throw new Error(\"'template.md does not exist.\");\n if (meta == null) throw new Error(\"'meta.md does not exist.\");\n if (meta?.title == null)\n throw new Error(\"'meta.md does not contain the title.\");\n\n const isDefault = !isDefaultPushed;\n status.push({\n pluginId: opts?.pluginId,\n id: templateId,\n locale,\n isValid: true,\n isDefault,\n title: meta.title,\n desc: meta.desc,\n });\n isDefaultPushed = true;\n } catch (err) {\n status.push({\n pluginId: opts?.pluginId,\n id: templateId,\n locale,\n isValid: false,\n invalidReason: (err as Error).message,\n });\n }\n }\n\n // eslint-disable-next-line no-console\n console.debug(`Template directory (${projectDirRoot}) has scanned`, {\n status,\n });\n\n return status;\n};\n\nexport const scanAllTemplates = async (\n projectDirRoot: string,\n opts?: {\n data?: GrowiTemplatePluginValidationData;\n pluginId?: string;\n returnsInvalidTemplates?: boolean;\n },\n): Promise<TemplateSummary[]> => {\n const data =\n opts?.data ?? validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const summaries: TemplateSummary[] = [];\n\n const distDirPath = path.resolve(projectDirRoot, 'dist');\n const distDirFiles = fs.readdirSync(distDirPath);\n\n for await (const templateId of distDirFiles) {\n const status = (\n await scanTemplate(projectDirRoot, templateId, data, {\n pluginId: opts?.pluginId,\n })\n )\n // omit invalid templates if `returnsInvalidTemplates` is true\n .filter((s) => (opts?.returnsInvalidTemplates ? true : s.isValid));\n\n // determine default locale\n const defaultTemplateStatus = status.find(\n (s) => 'isDefault' in s && s.isDefault,\n );\n\n if (\n defaultTemplateStatus == null ||\n !isTemplateStatusValid(defaultTemplateStatus)\n ) {\n continue;\n }\n\n summaries.push({\n // for the 'default' key\n default: defaultTemplateStatus,\n // for each locale keys\n ...Object.fromEntries(\n status.map((templateStatus) => [templateStatus.locale, templateStatus]),\n ),\n });\n }\n\n return summaries;\n};\n"],"names":["scanTemplate","projectDirRoot","templateId","data","opts","status","tplRootDirPath","path","isDefaultPushed","locale","tplDir","stats","getStatus","isTemplateExists","meta","isDefault","err","scanAllTemplates","validateTemplatePluginGrowiDirective","summaries","distDirPath","distDirFiles","fs","s","defaultTemplateStatus","isTemplateStatusValid","templateStatus"],"mappings":";;;;;AAYO,MAAMA,IAAe,OAC1BC,GACAC,GACAC,GACAC,MAG8B;AAC9B,QAAMC,IAA2B,CAAC,GAE5BC,IAAiBC,EAAK,QAAQN,GAAgB,QAAQC,CAAU;AAEtE,MAAIM,IAAkB;AACL,mBAAAC,KAAUN,EAAK,mBAAmB;AACjD,UAAMO,IAASH,EAAK,QAAQD,GAAgBG,CAAM;AAE9C,QAAA;AACI,YAAAE,IAAQ,MAAMC,EAAUF,CAAM,GAC9B,EAAE,kBAAAG,GAAkB,MAAAC,EAAA,IAASH;AAEnC,UAAI,CAACE,EAAwB,OAAA,IAAI,MAAM,8BAA8B;AACrE,UAAIC,KAAQ,KAAY,OAAA,IAAI,MAAM,0BAA0B;AAC5D,WAAIA,KAAA,gBAAAA,EAAM,UAAS;AACX,cAAA,IAAI,MAAM,sCAAsC;AAExD,YAAMC,IAAY,CAACP;AACnB,MAAAH,EAAO,KAAK;AAAA,QACV,UAAUD,KAAA,gBAAAA,EAAM;AAAA,QAChB,IAAIF;AAAA,QACJ,QAAAO;AAAA,QACA,SAAS;AAAA,QACT,WAAAM;AAAA,QACA,OAAOD,EAAK;AAAA,QACZ,MAAMA,EAAK;AAAA,MAAA,CACZ,GACiBN,IAAA;AAAA,aACXQ,GAAK;AACZ,MAAAX,EAAO,KAAK;AAAA,QACV,UAAUD,KAAA,gBAAAA,EAAM;AAAA,QAChB,IAAIF;AAAA,QACJ,QAAAO;AAAA,QACA,SAAS;AAAA,QACT,eAAgBO,EAAc;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EACH;AAIM,iBAAA,MAAM,uBAAuBf,CAAc,iBAAiB;AAAA,IAClE,QAAAI;AAAA,EAAA,CACD,GAEMA;AACT,GAEaY,IAAmB,OAC9BhB,GACAG,MAK+B;AAC/B,QAAMD,KACJC,KAAA,gBAAAA,EAAM,SAAQc,EAAqCjB,CAAc,GAE7DkB,IAA+B,CAAC,GAEhCC,IAAcb,EAAK,QAAQN,GAAgB,MAAM,GACjDoB,IAAeC,EAAG,YAAYF,CAAW;AAE/C,mBAAiBlB,KAAcmB,GAAc;AAC3C,UAAMhB,KACJ,MAAML,EAAaC,GAAgBC,GAAYC,GAAM;AAAA,MACnD,UAAUC,KAAA,gBAAAA,EAAM;AAAA,IAAA,CACjB,GAGA,OAAO,CAACmB,MAAOnB,KAAA,QAAAA,EAAM,0BAA0B,KAAOmB,EAAE,OAAQ,GAG7DC,IAAwBnB,EAAO;AAAA,MACnC,CAACkB,MAAM,eAAeA,KAAKA,EAAE;AAAA,IAC/B;AAEA,IACEC,KAAyB,QACzB,CAACC,EAAsBD,CAAqB,KAK9CL,EAAU,KAAK;AAAA;AAAA,MAEb,SAASK;AAAA;AAAA,MAET,GAAG,OAAO;AAAA,QACRnB,EAAO,IAAI,CAACqB,MAAmB,CAACA,EAAe,QAAQA,CAAc,CAAC;AAAA,MAAA;AAAA,IACxE,CACD;AAAA,EAAA;AAGI,SAAAP;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./scan.cjs"),o=require("./validate-growi-plugin-directive.cjs"),c=async l=>{const r=o.validateTemplatePluginGrowiDirective(l),i=await n.scanAllTemplates(l,{data:r,returnsInvalidTemplates:!0});if(Object.keys(i).length===0)throw new Error("This plugin does not have any templates");const s={};for(const a of i)s[a.default.id]=Object.values(a).map(e=>(e==null?void 0:e.isValid)??!1);for(const[a,e]of Object.entries(s))if(e.every(t=>t)||console.warn(`[WARN] Template '${a}' has some locales that status is invalid`),!e.some(t=>t))return!1;return!0};exports.validateAllTemplateLocales=c;
|
|
2
2
|
//# sourceMappingURL=validate-all-locales.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-all-locales.cjs","sources":["../../../../../src/v4/server/utils/template/validate-all-locales.ts"],"sourcesContent":["import { scanAllTemplates } from './scan';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\
|
|
1
|
+
{"version":3,"file":"validate-all-locales.cjs","sources":["../../../../../src/v4/server/utils/template/validate-all-locales.ts"],"sourcesContent":["import { scanAllTemplates } from './scan';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\nexport const validateAllTemplateLocales = async (\n projectDirRoot: string,\n): Promise<boolean> => {\n const data = validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const results = await scanAllTemplates(projectDirRoot, {\n data,\n returnsInvalidTemplates: true,\n });\n\n if (Object.keys(results).length === 0) {\n throw new Error('This plugin does not have any templates');\n }\n\n // construct map\n // key: id\n // value: isValid properties\n const idValidMap: { [id: string]: boolean[] } = {};\n for (const summary of results) {\n idValidMap[summary.default.id] = Object.values(summary).map(\n (s) => s?.isValid ?? false,\n );\n }\n\n for (const [id, validMap] of Object.entries(idValidMap)) {\n // warn\n if (!validMap.every((bool) => bool)) {\n // eslint-disable-next-line no-console\n console.warn(\n `[WARN] Template '${id}' has some locales that status is invalid`,\n );\n }\n\n // This means the template directory does not have any valid template\n if (!validMap.some((bool) => bool)) {\n return false;\n }\n }\n\n return true;\n};\n"],"names":["validateAllTemplateLocales","projectDirRoot","data","validateTemplatePluginGrowiDirective","results","scanAllTemplates","idValidMap","summary","s","id","validMap","bool"],"mappings":"iKAGaA,EAA6B,MACxCC,GACqB,CACf,MAAAC,EAAOC,uCAAqCF,CAAc,EAE1DG,EAAU,MAAMC,EAAA,iBAAiBJ,EAAgB,CACrD,KAAAC,EACA,wBAAyB,EAAA,CAC1B,EAED,GAAI,OAAO,KAAKE,CAAO,EAAE,SAAW,EAC5B,MAAA,IAAI,MAAM,yCAAyC,EAM3D,MAAME,EAA0C,CAAC,EACjD,UAAWC,KAAWH,EACpBE,EAAWC,EAAQ,QAAQ,EAAE,EAAI,OAAO,OAAOA,CAAO,EAAE,IACrDC,IAAMA,GAAA,YAAAA,EAAG,UAAW,EACvB,EAGF,SAAW,CAACC,EAAIC,CAAQ,IAAK,OAAO,QAAQJ,CAAU,EAUpD,GARKI,EAAS,MAAOC,GAASA,CAAI,GAExB,QAAA,KACN,oBAAoBF,CAAE,2CACxB,EAIE,CAACC,EAAS,KAAMC,GAASA,CAAI,EACxB,MAAA,GAIJ,MAAA,EACT"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { scanAllTemplates as
|
|
2
|
-
import { validateTemplatePluginGrowiDirective as
|
|
3
|
-
const
|
|
4
|
-
const r =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const s = {};
|
|
8
|
-
i.forEach((a) => {
|
|
9
|
-
s[a.default.id] = Object.values(a).map((e) => (e == null ? void 0 : e.isValid) ?? !1);
|
|
1
|
+
import { scanAllTemplates as o } from "./scan.js";
|
|
2
|
+
import { validateTemplatePluginGrowiDirective as n } from "./validate-growi-plugin-directive.js";
|
|
3
|
+
const d = async (l) => {
|
|
4
|
+
const r = n(l), s = await o(l, {
|
|
5
|
+
data: r,
|
|
6
|
+
returnsInvalidTemplates: !0
|
|
10
7
|
});
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
if (Object.keys(s).length === 0)
|
|
9
|
+
throw new Error("This plugin does not have any templates");
|
|
10
|
+
const i = {};
|
|
11
|
+
for (const a of s)
|
|
12
|
+
i[a.default.id] = Object.values(a).map(
|
|
13
|
+
(e) => (e == null ? void 0 : e.isValid) ?? !1
|
|
14
|
+
);
|
|
15
|
+
for (const [a, e] of Object.entries(i))
|
|
16
|
+
if (e.every((t) => t) || console.warn(
|
|
17
|
+
`[WARN] Template '${a}' has some locales that status is invalid`
|
|
18
|
+
), !e.some((t) => t))
|
|
13
19
|
return !1;
|
|
14
20
|
return !0;
|
|
15
21
|
};
|
|
16
22
|
export {
|
|
17
|
-
|
|
23
|
+
d as validateAllTemplateLocales
|
|
18
24
|
};
|
|
19
25
|
//# sourceMappingURL=validate-all-locales.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-all-locales.js","sources":["../../../../../src/v4/server/utils/template/validate-all-locales.ts"],"sourcesContent":["import { scanAllTemplates } from './scan';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\
|
|
1
|
+
{"version":3,"file":"validate-all-locales.js","sources":["../../../../../src/v4/server/utils/template/validate-all-locales.ts"],"sourcesContent":["import { scanAllTemplates } from './scan';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\nexport const validateAllTemplateLocales = async (\n projectDirRoot: string,\n): Promise<boolean> => {\n const data = validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const results = await scanAllTemplates(projectDirRoot, {\n data,\n returnsInvalidTemplates: true,\n });\n\n if (Object.keys(results).length === 0) {\n throw new Error('This plugin does not have any templates');\n }\n\n // construct map\n // key: id\n // value: isValid properties\n const idValidMap: { [id: string]: boolean[] } = {};\n for (const summary of results) {\n idValidMap[summary.default.id] = Object.values(summary).map(\n (s) => s?.isValid ?? false,\n );\n }\n\n for (const [id, validMap] of Object.entries(idValidMap)) {\n // warn\n if (!validMap.every((bool) => bool)) {\n // eslint-disable-next-line no-console\n console.warn(\n `[WARN] Template '${id}' has some locales that status is invalid`,\n );\n }\n\n // This means the template directory does not have any valid template\n if (!validMap.some((bool) => bool)) {\n return false;\n }\n }\n\n return true;\n};\n"],"names":["validateAllTemplateLocales","projectDirRoot","data","validateTemplatePluginGrowiDirective","results","scanAllTemplates","idValidMap","summary","s","id","validMap","bool"],"mappings":";;AAGa,MAAAA,IAA6B,OACxCC,MACqB;AACf,QAAAC,IAAOC,EAAqCF,CAAc,GAE1DG,IAAU,MAAMC,EAAiBJ,GAAgB;AAAA,IACrD,MAAAC;AAAA,IACA,yBAAyB;AAAA,EAAA,CAC1B;AAED,MAAI,OAAO,KAAKE,CAAO,EAAE,WAAW;AAC5B,UAAA,IAAI,MAAM,yCAAyC;AAM3D,QAAME,IAA0C,CAAC;AACjD,aAAWC,KAAWH;AACpB,IAAAE,EAAWC,EAAQ,QAAQ,EAAE,IAAI,OAAO,OAAOA,CAAO,EAAE;AAAA,MACtD,CAACC,OAAMA,KAAA,gBAAAA,EAAG,YAAW;AAAA,IACvB;AAGF,aAAW,CAACC,GAAIC,CAAQ,KAAK,OAAO,QAAQJ,CAAU;AAUpD,QARKI,EAAS,MAAM,CAACC,MAASA,CAAI,KAExB,QAAA;AAAA,MACN,oBAAoBF,CAAE;AAAA,IACxB,GAIE,CAACC,EAAS,KAAK,CAACC,MAASA,CAAI;AACxB,aAAA;AAIJ,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/template/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/template/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport type {\n GrowiPluginValidationData,\n GrowiTemplatePluginValidationData,\n} from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n/**\n * An utility for template plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateTemplatePluginGrowiDirective = (\n projectDirRoot: string,\n): GrowiTemplatePluginValidationData => {\n const data = validateGrowiDirective(projectDirRoot, GrowiPluginType.Template);\n\n const { growiPlugin } = data;\n\n // check supporting locales\n const supportingLocales: string[] | undefined = growiPlugin.locales;\n if (supportingLocales == null || supportingLocales.length === 0) {\n throw new GrowiPluginValidationError<\n GrowiPluginValidationData & { supportingLocales?: string[] }\n >(\n \"Template plugin must have 'supportingLocales' and that must have one or more locales\",\n {\n ...data,\n supportingLocales,\n },\n );\n }\n\n return {\n ...data,\n supportingLocales,\n };\n};\n"],"names":["validateTemplatePluginGrowiDirective","projectDirRoot","data","validateGrowiDirective","GrowiPluginType","growiPlugin","supportingLocales","GrowiPluginValidationError"],"mappings":"2OAaaA,EACXC,GACsC,CACtC,MAAMC,EAAOC,EAAA,uBAAuBF,EAAgBG,EAAAA,gBAAgB,QAAQ,EAEtE,CAAE,YAAAC,GAAgBH,EAGlBI,EAA0CD,EAAY,QAC5D,GAAIC,GAAqB,MAAQA,EAAkB,SAAW,EAC5D,MAAM,IAAIC,EAAA,2BAGR,uFACA,CACE,GAAGL,EACH,kBAAAI,CAAA,CAEJ,EAGK,MAAA,CACL,GAAGJ,EACH,kBAAAI,CACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/template/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/template/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport type {\n GrowiPluginValidationData,\n GrowiTemplatePluginValidationData,\n} from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n/**\n * An utility for template plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateTemplatePluginGrowiDirective = (\n projectDirRoot: string,\n): GrowiTemplatePluginValidationData => {\n const data = validateGrowiDirective(projectDirRoot, GrowiPluginType.Template);\n\n const { growiPlugin } = data;\n\n // check supporting locales\n const supportingLocales: string[] | undefined = growiPlugin.locales;\n if (supportingLocales == null || supportingLocales.length === 0) {\n throw new GrowiPluginValidationError<\n GrowiPluginValidationData & { supportingLocales?: string[] }\n >(\n \"Template plugin must have 'supportingLocales' and that must have one or more locales\",\n {\n ...data,\n supportingLocales,\n },\n );\n }\n\n return {\n ...data,\n supportingLocales,\n };\n};\n"],"names":["validateTemplatePluginGrowiDirective","projectDirRoot","data","validateGrowiDirective","GrowiPluginType","growiPlugin","supportingLocales","GrowiPluginValidationError"],"mappings":";;;AAaa,MAAAA,IAAuC,CAClDC,MACsC;AACtC,QAAMC,IAAOC,EAAuBF,GAAgBG,EAAgB,QAAQ,GAEtE,EAAE,aAAAC,MAAgBH,GAGlBI,IAA0CD,EAAY;AAC5D,MAAIC,KAAqB,QAAQA,EAAkB,WAAW;AAC5D,UAAM,IAAIC;AAAA,MAGR;AAAA,MACA;AAAA,QACE,GAAGL;AAAA,QACH,mBAAAI;AAAA,MAAA;AAAA,IAEJ;AAGK,SAAA;AAAA,IACL,GAAGJ;AAAA,IACH,mBAAAI;AAAA,EACF;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@growi/core"),n=require("../../../../model/growi-plugin-validation-error.cjs"),s=require("../common/validate-growi-plugin-directive.cjs"),h=l=>{const r=s.validateGrowiDirective(l,o.GrowiPluginType.Theme),{growiPlugin:e}=r;if(e.themes==null||!Array.isArray(e.themes)||e.themes.length===0)throw new n.GrowiPluginValidationError("Theme plugin must have 'themes' array and that must have one or more theme metadata");const a=[],
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@growi/core"),n=require("../../../../model/growi-plugin-validation-error.cjs"),s=require("../common/validate-growi-plugin-directive.cjs"),h=l=>{const r=s.validateGrowiDirective(l,o.GrowiPluginType.Theme),{growiPlugin:e}=r;if(e.themes==null||!Array.isArray(e.themes)||e.themes.length===0)throw new n.GrowiPluginValidationError("Theme plugin must have 'themes' array and that must have one or more theme metadata");const a=[],t=[];for(const i of e.themes)o.isGrowiThemeMetadata(i)?a.push(i):t.push(i);if(t.length>0)throw new n.GrowiPluginValidationError(`Some of theme metadata are invalid: ${t.toString()}`);return{...r,themes:a}};exports.validateThemePluginGrowiDirective=h;
|
|
2
2
|
//# sourceMappingURL=validate-growi-plugin-directive.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/theme/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiThemeMetadata } from '@growi/core';\nimport { GrowiPluginType, isGrowiThemeMetadata } from '@growi/core';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/theme/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiThemeMetadata } from '@growi/core';\nimport { GrowiPluginType, isGrowiThemeMetadata } from '@growi/core';\n\nimport type {\n GrowiPluginValidationData,\n GrowiThemePluginValidationData,\n} from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n/**\n * An utility for theme plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateThemePluginGrowiDirective = (\n projectDirRoot: string,\n): GrowiThemePluginValidationData => {\n const data = validateGrowiDirective(projectDirRoot, GrowiPluginType.Theme);\n\n const { growiPlugin } = data;\n\n // check themes\n if (\n growiPlugin.themes == null ||\n !Array.isArray(growiPlugin.themes) ||\n growiPlugin.themes.length === 0\n ) {\n throw new GrowiPluginValidationError<GrowiPluginValidationData>(\n \"Theme plugin must have 'themes' array and that must have one or more theme metadata\",\n );\n }\n\n const validMetadatas: GrowiThemeMetadata[] = [];\n const invalidObjects: unknown[] = [];\n for (const theme of growiPlugin.themes) {\n if (isGrowiThemeMetadata(theme)) {\n validMetadatas.push(theme);\n } else {\n invalidObjects.push(theme);\n }\n }\n\n if (invalidObjects.length > 0) {\n throw new GrowiPluginValidationError<GrowiPluginValidationData>(\n `Some of theme metadata are invalid: ${invalidObjects.toString()}`,\n );\n }\n\n return {\n ...data,\n themes: validMetadatas,\n };\n};\n"],"names":["validateThemePluginGrowiDirective","projectDirRoot","data","validateGrowiDirective","GrowiPluginType","growiPlugin","GrowiPluginValidationError","validMetadatas","invalidObjects","theme","isGrowiThemeMetadata"],"mappings":"2OAcaA,EACXC,GACmC,CACnC,MAAMC,EAAOC,EAAA,uBAAuBF,EAAgBG,EAAAA,gBAAgB,KAAK,EAEnE,CAAE,YAAAC,GAAgBH,EAGxB,GACEG,EAAY,QAAU,MACtB,CAAC,MAAM,QAAQA,EAAY,MAAM,GACjCA,EAAY,OAAO,SAAW,EAE9B,MAAM,IAAIC,EAAA,2BACR,qFACF,EAGF,MAAMC,EAAuC,CAAC,EACxCC,EAA4B,CAAC,EACxB,UAAAC,KAASJ,EAAY,OAC1BK,EAAAA,qBAAqBD,CAAK,EAC5BF,EAAe,KAAKE,CAAK,EAEzBD,EAAe,KAAKC,CAAK,EAIzB,GAAAD,EAAe,OAAS,EAC1B,MAAM,IAAIF,EAAA,2BACR,uCAAuCE,EAAe,UAAU,EAClE,EAGK,MAAA,CACL,GAAGN,EACH,OAAQK,CACV,CACF"}
|
|
@@ -2,21 +2,21 @@ import { GrowiPluginType as n, isGrowiThemeMetadata as h } from "@growi/core";
|
|
|
2
2
|
import { GrowiPluginValidationError as o } from "../../../../model/growi-plugin-validation-error.js";
|
|
3
3
|
import { validateGrowiDirective as s } from "../common/validate-growi-plugin-directive.js";
|
|
4
4
|
const w = (m) => {
|
|
5
|
-
const
|
|
5
|
+
const r = s(m, n.Theme), { growiPlugin: e } = r;
|
|
6
6
|
if (e.themes == null || !Array.isArray(e.themes) || e.themes.length === 0)
|
|
7
7
|
throw new o(
|
|
8
8
|
"Theme plugin must have 'themes' array and that must have one or more theme metadata"
|
|
9
9
|
);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
h(
|
|
13
|
-
|
|
10
|
+
const a = [], t = [];
|
|
11
|
+
for (const i of e.themes)
|
|
12
|
+
h(i) ? a.push(i) : t.push(i);
|
|
13
|
+
if (t.length > 0)
|
|
14
14
|
throw new o(
|
|
15
15
|
`Some of theme metadata are invalid: ${t.toString()}`
|
|
16
16
|
);
|
|
17
17
|
return {
|
|
18
|
-
...
|
|
19
|
-
themes:
|
|
18
|
+
...r,
|
|
19
|
+
themes: a
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/theme/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiThemeMetadata } from '@growi/core';\nimport { GrowiPluginType, isGrowiThemeMetadata } from '@growi/core';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/theme/validate-growi-plugin-directive.ts"],"sourcesContent":["import type { GrowiThemeMetadata } from '@growi/core';\nimport { GrowiPluginType, isGrowiThemeMetadata } from '@growi/core';\n\nimport type {\n GrowiPluginValidationData,\n GrowiThemePluginValidationData,\n} from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n/**\n * An utility for theme plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateThemePluginGrowiDirective = (\n projectDirRoot: string,\n): GrowiThemePluginValidationData => {\n const data = validateGrowiDirective(projectDirRoot, GrowiPluginType.Theme);\n\n const { growiPlugin } = data;\n\n // check themes\n if (\n growiPlugin.themes == null ||\n !Array.isArray(growiPlugin.themes) ||\n growiPlugin.themes.length === 0\n ) {\n throw new GrowiPluginValidationError<GrowiPluginValidationData>(\n \"Theme plugin must have 'themes' array and that must have one or more theme metadata\",\n );\n }\n\n const validMetadatas: GrowiThemeMetadata[] = [];\n const invalidObjects: unknown[] = [];\n for (const theme of growiPlugin.themes) {\n if (isGrowiThemeMetadata(theme)) {\n validMetadatas.push(theme);\n } else {\n invalidObjects.push(theme);\n }\n }\n\n if (invalidObjects.length > 0) {\n throw new GrowiPluginValidationError<GrowiPluginValidationData>(\n `Some of theme metadata are invalid: ${invalidObjects.toString()}`,\n );\n }\n\n return {\n ...data,\n themes: validMetadatas,\n };\n};\n"],"names":["validateThemePluginGrowiDirective","projectDirRoot","data","validateGrowiDirective","GrowiPluginType","growiPlugin","GrowiPluginValidationError","validMetadatas","invalidObjects","theme","isGrowiThemeMetadata"],"mappings":";;;AAca,MAAAA,IAAoC,CAC/CC,MACmC;AACnC,QAAMC,IAAOC,EAAuBF,GAAgBG,EAAgB,KAAK,GAEnE,EAAE,aAAAC,MAAgBH;AAGxB,MACEG,EAAY,UAAU,QACtB,CAAC,MAAM,QAAQA,EAAY,MAAM,KACjCA,EAAY,OAAO,WAAW;AAE9B,UAAM,IAAIC;AAAA,MACR;AAAA,IACF;AAGF,QAAMC,IAAuC,CAAC,GACxCC,IAA4B,CAAC;AACxB,aAAAC,KAASJ,EAAY;AAC1B,IAAAK,EAAqBD,CAAK,IAC5BF,EAAe,KAAKE,CAAK,IAEzBD,EAAe,KAAKC,CAAK;AAIzB,MAAAD,EAAe,SAAS;AAC1B,UAAM,IAAIF;AAAA,MACR,uCAAuCE,EAAe,UAAU;AAAA,IAClE;AAGK,SAAA;AAAA,IACL,GAAGN;AAAA,IACH,QAAQK;AAAA,EACV;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.cjs","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"template.cjs","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type { TemplateStatus, TemplateSummary } from '../interfaces';\n\nexport const getLocalizedTemplate = (\n templateSummary: TemplateSummary | undefined,\n locale?: string,\n): TemplateStatus | undefined => {\n if (templateSummary == null) {\n return undefined;\n }\n\n return locale != null && locale in templateSummary\n ? templateSummary[locale]\n : templateSummary.default;\n};\n\nexport const extractSupportedLocales = (\n templateSummary: TemplateSummary | undefined,\n): Set<string> | undefined => {\n if (templateSummary == null) {\n return undefined;\n }\n\n return new Set(Object.values(templateSummary).map((s) => s.locale));\n};\n"],"names":["getLocalizedTemplate","templateSummary","locale","extractSupportedLocales","s"],"mappings":"gFAEa,MAAAA,EAAuB,CAClCC,EACAC,IAC+B,CAC/B,GAAID,GAAmB,KAIvB,OAAOC,GAAU,MAAQA,KAAUD,EAC/BA,EAAgBC,CAAM,EACtBD,EAAgB,OACtB,EAEaE,EACXF,GAC4B,CAC5B,GAAIA,GAAmB,KAIhB,OAAA,IAAI,IAAI,OAAO,OAAOA,CAAe,EAAE,IAAKG,GAAMA,EAAE,MAAM,CAAC,CACpE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TemplateStatus, TemplateSummary } from '../interfaces';
|
|
2
2
|
|
|
3
3
|
export declare const getLocalizedTemplate: (templateSummary: TemplateSummary | undefined, locale?: string) => TemplateStatus | undefined;
|
|
4
4
|
export declare const extractSupportedLocales: (templateSummary: TemplateSummary | undefined) => Set<string> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"template.js","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type { TemplateStatus, TemplateSummary } from '../interfaces';\n\nexport const getLocalizedTemplate = (\n templateSummary: TemplateSummary | undefined,\n locale?: string,\n): TemplateStatus | undefined => {\n if (templateSummary == null) {\n return undefined;\n }\n\n return locale != null && locale in templateSummary\n ? templateSummary[locale]\n : templateSummary.default;\n};\n\nexport const extractSupportedLocales = (\n templateSummary: TemplateSummary | undefined,\n): Set<string> | undefined => {\n if (templateSummary == null) {\n return undefined;\n }\n\n return new Set(Object.values(templateSummary).map((s) => s.locale));\n};\n"],"names":["getLocalizedTemplate","templateSummary","locale","extractSupportedLocales","s"],"mappings":"AAEa,MAAAA,IAAuB,CAClCC,GACAC,MAC+B;AAC/B,MAAID,KAAmB;AAIvB,WAAOC,KAAU,QAAQA,KAAUD,IAC/BA,EAAgBC,CAAM,IACtBD,EAAgB;AACtB,GAEaE,IAA0B,CACrCF,MAC4B;AAC5B,MAAIA,KAAmB;AAIhB,WAAA,IAAI,IAAI,OAAO,OAAOA,CAAe,EAAE,IAAI,CAACG,MAAMA,EAAE,MAAM,CAAC;AACpE;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@growi/pluginkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-next.d92d1aa0318d5fdc7fe811d2d94d2cd9e881ec33",
|
|
4
4
|
"description": "Plugin kit for GROWI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"extensible-custom-error": "^0.0.7",
|
|
15
|
+
"@growi/core": "^2.0.0-next.d92d1aa0318d5fdc7fe811d2d94d2cd9e881ec33"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/react": "^18.2.14"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"clean": "shx rm -rf dist",
|
|
23
23
|
"dev": "vite build --mode dev",
|
|
24
24
|
"watch": "pnpm run dev -w --emptyOutDir=false",
|
|
25
|
-
"lint:js": "
|
|
25
|
+
"lint:js": "biome check",
|
|
26
26
|
"lint:typecheck": "vue-tsc --noEmit",
|
|
27
27
|
"lint": "npm-run-all -p lint:*",
|
|
28
28
|
"test": "vitest run --coverage"
|