@growi/pluginkit 1.0.0-next.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.
Files changed (108) hide show
  1. package/dist/index.cjs +2 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/model/growi-plugin-package-data.cjs +2 -0
  7. package/dist/model/growi-plugin-package-data.cjs.map +1 -0
  8. package/dist/model/growi-plugin-package-data.d.ts +11 -0
  9. package/dist/model/growi-plugin-package-data.js +2 -0
  10. package/dist/model/growi-plugin-package-data.js.map +1 -0
  11. package/dist/model/growi-plugin-validation-data.cjs +2 -0
  12. package/dist/model/growi-plugin-validation-data.cjs.map +1 -0
  13. package/dist/model/growi-plugin-validation-data.d.ts +13 -0
  14. package/dist/model/growi-plugin-validation-data.js +2 -0
  15. package/dist/model/growi-plugin-validation-data.js.map +1 -0
  16. package/dist/model/growi-plugin-validation-error.cjs +2 -0
  17. package/dist/model/growi-plugin-validation-error.cjs.map +1 -0
  18. package/dist/model/growi-plugin-validation-error.d.ts +7 -0
  19. package/dist/model/growi-plugin-validation-error.js +10 -0
  20. package/dist/model/growi-plugin-validation-error.js.map +1 -0
  21. package/dist/model/index.cjs +2 -0
  22. package/dist/model/index.cjs.map +1 -0
  23. package/dist/model/index.d.ts +3 -0
  24. package/dist/model/index.js +5 -0
  25. package/dist/model/index.js.map +1 -0
  26. package/dist/v4/index.cjs +2 -0
  27. package/dist/v4/index.cjs.map +1 -0
  28. package/dist/v4/index.d.ts +2 -0
  29. package/dist/v4/index.js +8 -0
  30. package/dist/v4/index.js.map +1 -0
  31. package/dist/v4/interfaces/index.cjs +2 -0
  32. package/dist/v4/interfaces/index.cjs.map +1 -0
  33. package/dist/v4/interfaces/index.d.ts +1 -0
  34. package/dist/v4/interfaces/index.js +5 -0
  35. package/dist/v4/interfaces/index.js.map +1 -0
  36. package/dist/v4/interfaces/template.cjs +2 -0
  37. package/dist/v4/interfaces/template.cjs.map +1 -0
  38. package/dist/v4/interfaces/template.d.ts +21 -0
  39. package/dist/v4/interfaces/template.js +7 -0
  40. package/dist/v4/interfaces/template.js.map +1 -0
  41. package/dist/v4/server/index.cjs +2 -0
  42. package/dist/v4/server/index.cjs.map +1 -0
  43. package/dist/v4/server/index.d.ts +1 -0
  44. package/dist/v4/server/index.js +16 -0
  45. package/dist/v4/server/index.js.map +1 -0
  46. package/dist/v4/server/utils/common/import-package-json.cjs +2 -0
  47. package/dist/v4/server/utils/common/import-package-json.cjs.map +1 -0
  48. package/dist/v4/server/utils/common/import-package-json.d.ts +3 -0
  49. package/dist/v4/server/utils/common/import-package-json.js +10 -0
  50. package/dist/v4/server/utils/common/import-package-json.js.map +1 -0
  51. package/dist/v4/server/utils/common/import-package-json.spec.d.ts +1 -0
  52. package/dist/v4/server/utils/common/index.cjs +2 -0
  53. package/dist/v4/server/utils/common/index.cjs.map +1 -0
  54. package/dist/v4/server/utils/common/index.d.ts +2 -0
  55. package/dist/v4/server/utils/common/index.js +7 -0
  56. package/dist/v4/server/utils/common/index.js.map +1 -0
  57. package/dist/v4/server/utils/common/validate-growi-plugin-directive.cjs +2 -0
  58. package/dist/v4/server/utils/common/validate-growi-plugin-directive.cjs.map +1 -0
  59. package/dist/v4/server/utils/common/validate-growi-plugin-directive.d.ts +4 -0
  60. package/dist/v4/server/utils/common/validate-growi-plugin-directive.js +20 -0
  61. package/dist/v4/server/utils/common/validate-growi-plugin-directive.js.map +1 -0
  62. package/dist/v4/server/utils/common/validate-growi-plugin-directive.spec.d.ts +1 -0
  63. package/dist/v4/server/utils/index.cjs +2 -0
  64. package/dist/v4/server/utils/index.cjs.map +1 -0
  65. package/dist/v4/server/utils/index.d.ts +2 -0
  66. package/dist/v4/server/utils/index.js +16 -0
  67. package/dist/v4/server/utils/index.js.map +1 -0
  68. package/dist/v4/server/utils/template/get-markdown.cjs +2 -0
  69. package/dist/v4/server/utils/template/get-markdown.cjs.map +1 -0
  70. package/dist/v4/server/utils/template/get-markdown.d.ts +1 -0
  71. package/dist/v4/server/utils/template/get-markdown.js +14 -0
  72. package/dist/v4/server/utils/template/get-markdown.js.map +1 -0
  73. package/dist/v4/server/utils/template/get-status.cjs +2 -0
  74. package/dist/v4/server/utils/template/get-status.cjs.map +1 -0
  75. package/dist/v4/server/utils/template/get-status.d.ts +8 -0
  76. package/dist/v4/server/utils/template/get-status.js +15 -0
  77. package/dist/v4/server/utils/template/get-status.js.map +1 -0
  78. package/dist/v4/server/utils/template/index.cjs +2 -0
  79. package/dist/v4/server/utils/template/index.cjs.map +1 -0
  80. package/dist/v4/server/utils/template/index.d.ts +4 -0
  81. package/dist/v4/server/utils/template/index.js +12 -0
  82. package/dist/v4/server/utils/template/index.js.map +1 -0
  83. package/dist/v4/server/utils/template/scan.cjs +2 -0
  84. package/dist/v4/server/utils/template/scan.cjs.map +1 -0
  85. package/dist/v4/server/utils/template/scan.d.ts +11 -0
  86. package/dist/v4/server/utils/template/scan.js +60 -0
  87. package/dist/v4/server/utils/template/scan.js.map +1 -0
  88. package/dist/v4/server/utils/template/validate-all-locales.cjs +2 -0
  89. package/dist/v4/server/utils/template/validate-all-locales.cjs.map +1 -0
  90. package/dist/v4/server/utils/template/validate-all-locales.d.ts +1 -0
  91. package/dist/v4/server/utils/template/validate-all-locales.js +19 -0
  92. package/dist/v4/server/utils/template/validate-all-locales.js.map +1 -0
  93. package/dist/v4/server/utils/template/validate-growi-plugin-directive.cjs +2 -0
  94. package/dist/v4/server/utils/template/validate-growi-plugin-directive.cjs.map +1 -0
  95. package/dist/v4/server/utils/template/validate-growi-plugin-directive.d.ts +7 -0
  96. package/dist/v4/server/utils/template/validate-growi-plugin-directive.js +22 -0
  97. package/dist/v4/server/utils/template/validate-growi-plugin-directive.js.map +1 -0
  98. package/dist/v4/utils/index.cjs +2 -0
  99. package/dist/v4/utils/index.cjs.map +1 -0
  100. package/dist/v4/utils/index.d.ts +1 -0
  101. package/dist/v4/utils/index.js +6 -0
  102. package/dist/v4/utils/index.js.map +1 -0
  103. package/dist/v4/utils/template.cjs +2 -0
  104. package/dist/v4/utils/template.cjs.map +1 -0
  105. package/dist/v4/utils/template.d.ts +4 -0
  106. package/dist/v4/utils/template.js +12 -0
  107. package/dist/v4/utils/template.js.map +1 -0
  108. package/package.json +28 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./model/growi-plugin-validation-error.cjs");exports.GrowiPluginValidationError=r.GrowiPluginValidationError;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './model';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { GrowiPluginValidationError as i } from "./model/growi-plugin-validation-error.js";
2
+ export {
3
+ i as GrowiPluginValidationError
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=growi-plugin-package-data.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growi-plugin-package-data.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { GrowiPluginType } from '@growi/core';
2
+
3
+ export type GrowiPluginDirective = {
4
+ [key: string]: any;
5
+ schemaVersion: number;
6
+ types: GrowiPluginType[];
7
+ };
8
+ export type GrowiPluginPackageData = {
9
+ [key: string]: any;
10
+ growiPlugin: GrowiPluginDirective;
11
+ };
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=growi-plugin-package-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growi-plugin-package-data.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=growi-plugin-validation-data.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growi-plugin-validation-data.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { GrowiPluginDirective } from './growi-plugin-package-data';
2
+ import { GrowiPluginType } from '@growi/core';
3
+
4
+ export type GrowiPluginValidationData = {
5
+ projectDirRoot: string;
6
+ growiPlugin: GrowiPluginDirective;
7
+ schemaVersion: number;
8
+ expectedPluginType?: GrowiPluginType;
9
+ actualPluginTypes?: GrowiPluginType[];
10
+ };
11
+ export type GrowiTemplatePluginValidationData = GrowiPluginValidationData & {
12
+ supportingLocales: string[];
13
+ };
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=growi-plugin-validation-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growi-plugin-validation-data.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("extensible-custom-error");class e extends o{constructor(r,t){super(r),this.data=t}}exports.GrowiPluginValidationError=e;
2
+ //# sourceMappingURL=growi-plugin-validation-error.cjs.map
@@ -0,0 +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\n\nexport class GrowiPluginValidationError<E extends Partial<GrowiPluginValidationData> = Partial<GrowiPluginValidationData>> extends ExtensibleCustomError {\n\n data?: E;\n\n constructor(message: string, data?: E) {\n super(message);\n this.data = data;\n }\n\n}\n"],"names":["GrowiPluginValidationError","ExtensibleCustomError","message","data"],"mappings":"2HAKO,MAAMA,UAAsHC,CAAsB,CAIvJ,YAAYC,EAAiBC,EAAU,CACrC,MAAMD,CAAO,EACb,KAAK,KAAOC,CACd,CAEF"}
@@ -0,0 +1,7 @@
1
+ import { GrowiPluginValidationData } from './growi-plugin-validation-data';
2
+ import { default as ExtensibleCustomError } from 'extensible-custom-error';
3
+
4
+ export declare class GrowiPluginValidationError<E extends Partial<GrowiPluginValidationData> = Partial<GrowiPluginValidationData>> extends ExtensibleCustomError {
5
+ data?: E;
6
+ constructor(message: string, data?: E);
7
+ }
@@ -0,0 +1,10 @@
1
+ import t from "extensible-custom-error";
2
+ class e extends t {
3
+ constructor(r, o) {
4
+ super(r), this.data = o;
5
+ }
6
+ }
7
+ export {
8
+ e as GrowiPluginValidationError
9
+ };
10
+ //# sourceMappingURL=growi-plugin-validation-error.js.map
@@ -0,0 +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\n\nexport class GrowiPluginValidationError<E extends Partial<GrowiPluginValidationData> = Partial<GrowiPluginValidationData>> extends ExtensibleCustomError {\n\n data?: E;\n\n constructor(message: string, data?: E) {\n super(message);\n this.data = data;\n }\n\n}\n"],"names":["GrowiPluginValidationError","ExtensibleCustomError","message","data"],"mappings":";AAKO,MAAMA,UAAsHC,EAAsB;AAAA,EAIvJ,YAAYC,GAAiBC,GAAU;AACrC,UAAMD,CAAO,GACb,KAAK,OAAOC;AAAA,EACd;AAEF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./growi-plugin-validation-error.cjs");exports.GrowiPluginValidationError=r.GrowiPluginValidationError;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './growi-plugin-package-data';
2
+ export * from './growi-plugin-validation-data';
3
+ export * from './growi-plugin-validation-error';
@@ -0,0 +1,5 @@
1
+ import { GrowiPluginValidationError as i } from "./growi-plugin-validation-error.js";
2
+ export {
3
+ i as GrowiPluginValidationError
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./interfaces/template.cjs"),e=require("./utils/template.cjs");exports.isTemplateStatusValid=t.isTemplateStatusValid;exports.extractSupportedLocales=e.extractSupportedLocales;exports.getLocalizedTemplate=e.getLocalizedTemplate;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './interfaces';
2
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ import { isTemplateStatusValid as a } from "./interfaces/template.js";
2
+ import { extractSupportedLocales as p, getLocalizedTemplate as r } from "./utils/template.js";
3
+ export {
4
+ p as extractSupportedLocales,
5
+ r as getLocalizedTemplate,
6
+ a as isTemplateStatusValid
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./template.cjs");exports.isTemplateStatusValid=e.isTemplateStatusValid;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './template';
@@ -0,0 +1,5 @@
1
+ import { isTemplateStatusValid as e } from "./template.js";
2
+ export {
3
+ e as isTemplateStatusValid
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return t.isValid}exports.isTemplateStatusValid=e;
2
+ //# sourceMappingURL=template.cjs.map
@@ -0,0 +1 @@
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(status: TemplateStatus): 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,EAAsBC,EAAuD,CAC3F,OAAOA,EAAO,OAChB"}
@@ -0,0 +1,21 @@
1
+ export type TemplateStatusBasis = {
2
+ id: string;
3
+ locale: string;
4
+ pluginId?: string;
5
+ };
6
+ export type TemplateStatusValid = TemplateStatusBasis & {
7
+ isValid: true;
8
+ isDefault: boolean;
9
+ title: string;
10
+ desc?: string;
11
+ };
12
+ export type TemplateStatusInvalid = TemplateStatusBasis & {
13
+ isValid: false;
14
+ invalidReason: string;
15
+ };
16
+ export type TemplateStatus = TemplateStatusValid | TemplateStatusInvalid;
17
+ export declare function isTemplateStatusValid(status: TemplateStatus): status is TemplateStatusValid;
18
+ export type TemplateSummary = {
19
+ default: TemplateStatusValid;
20
+ [locale: string]: TemplateStatus;
21
+ };
@@ -0,0 +1,7 @@
1
+ function i(t) {
2
+ return t.isValid;
3
+ }
4
+ export {
5
+ i as isTemplateStatusValid
6
+ };
7
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
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(status: TemplateStatus): 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,EAAsBC,GAAuD;AAC3F,SAAOA,EAAO;AAChB;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./utils/common/import-package-json.cjs"),i=require("./utils/common/validate-growi-plugin-directive.cjs"),t=require("./utils/template/get-markdown.cjs"),e=require("./utils/template/scan.cjs"),l=require("./utils/template/validate-all-locales.cjs"),r=require("./utils/template/validate-growi-plugin-directive.cjs");exports.importPackageJson=a.importPackageJson;exports.validateGrowiDirective=i.validateGrowiDirective;exports.getMarkdown=t.getMarkdown;exports.scanAllTemplates=e.scanAllTemplates;exports.scanTemplate=e.scanTemplate;exports.validateAllTemplateLocales=l.validateAllTemplateLocales;exports.validateTemplatePluginGrowiDirective=r.validateTemplatePluginGrowiDirective;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './utils';
@@ -0,0 +1,16 @@
1
+ import { importPackageJson as r } from "./utils/common/import-package-json.js";
2
+ import { validateGrowiDirective as a } from "./utils/common/validate-growi-plugin-directive.js";
3
+ import { getMarkdown as i } from "./utils/template/get-markdown.js";
4
+ import { scanAllTemplates as p, scanTemplate as c } from "./utils/template/scan.js";
5
+ import { validateAllTemplateLocales as x } from "./utils/template/validate-all-locales.js";
6
+ import { validateTemplatePluginGrowiDirective as s } from "./utils/template/validate-growi-plugin-directive.js";
7
+ export {
8
+ i as getMarkdown,
9
+ r as importPackageJson,
10
+ p as scanAllTemplates,
11
+ c as scanTemplate,
12
+ x as validateAllTemplateLocales,
13
+ a as validateGrowiDirective,
14
+ s as validateTemplatePluginGrowiDirective
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=import-package-json.cjs.map
@@ -0,0 +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":"wHAKaA,EAAqBC,GAAmD,CACnF,MAAMC,EAAiBC,EAAK,QAAQF,EAAgB,cAAc,EAClE,OAAO,KAAK,MAAMG,EAAAA,aAAaF,EAAgB,OAAO,CAAC,CACzD"}
@@ -0,0 +1,3 @@
1
+ import { GrowiPluginPackageData } from '../../../../model';
2
+
3
+ export declare const importPackageJson: (projectDirRoot: string) => GrowiPluginPackageData;
@@ -0,0 +1,10 @@
1
+ import { readFileSync as e } from "fs";
2
+ import a from "path";
3
+ const n = (o) => {
4
+ const r = a.resolve(o, "package.json");
5
+ return JSON.parse(e(r, "utf-8"));
6
+ };
7
+ export {
8
+ n as importPackageJson
9
+ };
10
+ //# sourceMappingURL=import-package-json.js.map
@@ -0,0 +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,CAACC,MAAmD;AACnF,QAAMC,IAAiBC,EAAK,QAAQF,GAAgB,cAAc;AAClE,SAAO,KAAK,MAAMG,EAAaF,GAAgB,OAAO,CAAC;AACzD;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./import-package-json.cjs"),i=require("./validate-growi-plugin-directive.cjs");exports.importPackageJson=e.importPackageJson;exports.validateGrowiDirective=i.validateGrowiDirective;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './import-package-json';
2
+ export * from './validate-growi-plugin-directive';
@@ -0,0 +1,7 @@
1
+ import { importPackageJson as e } from "./import-package-json.js";
2
+ import { validateGrowiDirective as t } from "./validate-growi-plugin-directive.js";
3
+ export {
4
+ e as importPackageJson,
5
+ t as validateGrowiDirective
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=validate-growi-plugin-directive.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-growi-plugin-directive.cjs","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport { type GrowiPluginValidationData, GrowiPluginValidationError } from '../../../../model';\n\nimport { importPackageJson } from './import-package-json';\n\n\nexport const validateGrowiDirective = (projectDirRoot: string, expectedPluginType?: GrowiPluginType): GrowiPluginValidationData => {\n const pkg = importPackageJson(projectDirRoot);\n\n const { growiPlugin } = pkg;\n\n const data: GrowiPluginValidationData = { projectDirRoot, schemaVersion: NaN, growiPlugin };\n\n if (growiPlugin == null) {\n throw new GrowiPluginValidationError(\"The package.json does not have 'growiPlugin' directive.\", data);\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(\"The growiPlugin directive must have a valid 'schemaVersion' directive.\", data);\n }\n\n const types: GrowiPluginType[] = growiPlugin.types;\n data.actualPluginTypes = types;\n if (types == null) {\n throw new GrowiPluginValidationError(\"The growiPlugin directive does not have 'types' directive.\", data);\n }\n\n // type checking\n if (expectedPluginType != null) {\n data.expectedPluginType = expectedPluginType;\n\n if (!types.includes(expectedPluginType)) {\n throw new GrowiPluginValidationError(\"The growiPlugin directive does not have expected plugin type in 'types' directive.\", data);\n }\n }\n\n return data;\n};\n"],"names":["validateGrowiDirective","projectDirRoot","expectedPluginType","pkg","importPackageJson","growiPlugin","data","GrowiPluginValidationError","schemaVersion","types"],"mappings":"8LAOaA,EAAyB,CAACC,EAAwBC,IAAoE,CAC3H,MAAAC,EAAMC,oBAAkBH,CAAc,EAEtC,CAAE,YAAAI,CAAgB,EAAAF,EAElBG,EAAkC,CAAE,eAAAL,EAAgB,cAAe,IAAK,YAAAI,CAAY,EAE1F,GAAIA,GAAe,KACX,MAAA,IAAIE,EAA2B,2BAAA,0DAA2DD,CAAI,EAIhG,MAAAE,EAAgB,OAAOH,EAAY,aAAa,EAEtD,GADAC,EAAK,cAAgBE,EACjB,OAAO,MAAMA,CAAa,GAAKA,EAAgB,EAC3C,MAAA,IAAID,EAA2B,2BAAA,yEAA0ED,CAAI,EAGrH,MAAMG,EAA2BJ,EAAY,MAE7C,GADAC,EAAK,kBAAoBG,EACrBA,GAAS,KACL,MAAA,IAAIF,EAA2B,2BAAA,6DAA8DD,CAAI,EAIzG,GAAIJ,GAAsB,OACxBI,EAAK,mBAAqBJ,EAEtB,CAACO,EAAM,SAASP,CAAkB,GAC9B,MAAA,IAAIK,EAA2B,2BAAA,qFAAsFD,CAAI,EAI5H,OAAAA,CACT"}
@@ -0,0 +1,4 @@
1
+ import { GrowiPluginValidationData } from '../../../../model';
2
+ import { GrowiPluginType } from '@growi/core';
3
+
4
+ export declare const validateGrowiDirective: (projectDirRoot: string, expectedPluginType?: GrowiPluginType) => GrowiPluginValidationData;
@@ -0,0 +1,20 @@
1
+ import { GrowiPluginValidationError as o } from "../../../../model/growi-plugin-validation-error.js";
2
+ import { importPackageJson as c } from "./import-package-json.js";
3
+ const u = (s, r) => {
4
+ const a = c(s), { growiPlugin: i } = a, e = { projectDirRoot: s, schemaVersion: NaN, growiPlugin: i };
5
+ if (i == null)
6
+ throw new o("The package.json does not have 'growiPlugin' directive.", e);
7
+ const n = Number(i.schemaVersion);
8
+ if (e.schemaVersion = n, Number.isNaN(n) || n < 4)
9
+ throw new o("The growiPlugin directive must have a valid 'schemaVersion' directive.", e);
10
+ const t = i.types;
11
+ if (e.actualPluginTypes = t, t == null)
12
+ throw new o("The growiPlugin directive does not have 'types' directive.", e);
13
+ if (r != null && (e.expectedPluginType = r, !t.includes(r)))
14
+ throw new o("The growiPlugin directive does not have expected plugin type in 'types' directive.", e);
15
+ return e;
16
+ };
17
+ export {
18
+ u as validateGrowiDirective
19
+ };
20
+ //# sourceMappingURL=validate-growi-plugin-directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-growi-plugin-directive.js","sources":["../../../../../src/v4/server/utils/common/validate-growi-plugin-directive.ts"],"sourcesContent":["import { GrowiPluginType } from '@growi/core';\n\nimport { type GrowiPluginValidationData, GrowiPluginValidationError } from '../../../../model';\n\nimport { importPackageJson } from './import-package-json';\n\n\nexport const validateGrowiDirective = (projectDirRoot: string, expectedPluginType?: GrowiPluginType): GrowiPluginValidationData => {\n const pkg = importPackageJson(projectDirRoot);\n\n const { growiPlugin } = pkg;\n\n const data: GrowiPluginValidationData = { projectDirRoot, schemaVersion: NaN, growiPlugin };\n\n if (growiPlugin == null) {\n throw new GrowiPluginValidationError(\"The package.json does not have 'growiPlugin' directive.\", data);\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(\"The growiPlugin directive must have a valid 'schemaVersion' directive.\", data);\n }\n\n const types: GrowiPluginType[] = growiPlugin.types;\n data.actualPluginTypes = types;\n if (types == null) {\n throw new GrowiPluginValidationError(\"The growiPlugin directive does not have 'types' directive.\", data);\n }\n\n // type checking\n if (expectedPluginType != null) {\n data.expectedPluginType = expectedPluginType;\n\n if (!types.includes(expectedPluginType)) {\n throw new GrowiPluginValidationError(\"The growiPlugin directive does not have expected plugin type in 'types' directive.\", data);\n }\n }\n\n return data;\n};\n"],"names":["validateGrowiDirective","projectDirRoot","expectedPluginType","pkg","importPackageJson","growiPlugin","data","GrowiPluginValidationError","schemaVersion","types"],"mappings":";;AAOa,MAAAA,IAAyB,CAACC,GAAwBC,MAAoE;AAC3H,QAAAC,IAAMC,EAAkBH,CAAc,GAEtC,EAAE,aAAAI,EAAgB,IAAAF,GAElBG,IAAkC,EAAE,gBAAAL,GAAgB,eAAe,KAAK,aAAAI,EAAY;AAE1F,MAAIA,KAAe;AACX,UAAA,IAAIE,EAA2B,2DAA2DD,CAAI;AAIhG,QAAAE,IAAgB,OAAOH,EAAY,aAAa;AAEtD,MADAC,EAAK,gBAAgBE,GACjB,OAAO,MAAMA,CAAa,KAAKA,IAAgB;AAC3C,UAAA,IAAID,EAA2B,0EAA0ED,CAAI;AAGrH,QAAMG,IAA2BJ,EAAY;AAE7C,MADAC,EAAK,oBAAoBG,GACrBA,KAAS;AACL,UAAA,IAAIF,EAA2B,8DAA8DD,CAAI;AAIzG,MAAIJ,KAAsB,SACxBI,EAAK,qBAAqBJ,GAEtB,CAACO,EAAM,SAASP,CAAkB;AAC9B,UAAA,IAAIK,EAA2B,sFAAsFD,CAAI;AAI5H,SAAAA;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./common/import-package-json.cjs"),i=require("./common/validate-growi-plugin-directive.cjs"),t=require("./template/get-markdown.cjs"),e=require("./template/scan.cjs"),l=require("./template/validate-all-locales.cjs"),r=require("./template/validate-growi-plugin-directive.cjs");exports.importPackageJson=a.importPackageJson;exports.validateGrowiDirective=i.validateGrowiDirective;exports.getMarkdown=t.getMarkdown;exports.scanAllTemplates=e.scanAllTemplates;exports.scanTemplate=e.scanTemplate;exports.validateAllTemplateLocales=l.validateAllTemplateLocales;exports.validateTemplatePluginGrowiDirective=r.validateTemplatePluginGrowiDirective;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './template';
@@ -0,0 +1,16 @@
1
+ import { importPackageJson as r } from "./common/import-package-json.js";
2
+ import { validateGrowiDirective as a } from "./common/validate-growi-plugin-directive.js";
3
+ import { getMarkdown as i } from "./template/get-markdown.js";
4
+ import { scanAllTemplates as p, scanTemplate as c } from "./template/scan.js";
5
+ import { validateAllTemplateLocales as x } from "./template/validate-all-locales.js";
6
+ import { validateTemplatePluginGrowiDirective as s } from "./template/validate-growi-plugin-directive.js";
7
+ export {
8
+ i as getMarkdown,
9
+ r as importPackageJson,
10
+ p as scanAllTemplates,
11
+ c as scanTemplate,
12
+ x as validateAllTemplateLocales,
13
+ a as validateGrowiDirective,
14
+ s as validateTemplatePluginGrowiDirective
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=get-markdown.cjs.map
@@ -0,0 +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\n\nexport const getMarkdown = async(projectDirRoot: string, templateId: string, locale: string): 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":"sJAMaA,EAAc,MAAMC,EAAwBC,EAAoBC,IAAoC,CAC/G,MAAMC,EAASC,EAAK,QAAQJ,EAAgB,OAAQC,EAAYC,CAAM,EAEhE,CAAE,iBAAAG,CAAqB,EAAA,MAAMC,YAAUH,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"}
@@ -0,0 +1 @@
1
+ export declare const getMarkdown: (projectDirRoot: string, templateId: string, locale: string) => Promise<string>;
@@ -0,0 +1,14 @@
1
+ import i from "fs";
2
+ import e from "path";
3
+ import { getStatus as m } from "./get-status.js";
4
+ const l = async (o, r, s) => {
5
+ const t = e.resolve(o, "dist", r, s), { isTemplateExists: n } = await m(t);
6
+ if (!n)
7
+ throw new Error("'template.md does not exist.");
8
+ const a = e.resolve(t, "template.md");
9
+ return i.readFileSync(a, { encoding: "utf-8" });
10
+ };
11
+ export {
12
+ l as getMarkdown
13
+ };
14
+ //# sourceMappingURL=get-markdown.js.map
@@ -0,0 +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\n\nexport const getMarkdown = async(projectDirRoot: string, templateId: string, locale: string): 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":";;;AAMO,MAAMA,IAAc,OAAMC,GAAwBC,GAAoBC,MAAoC;AAC/G,QAAMC,IAASC,EAAK,QAAQJ,GAAgB,QAAQC,GAAYC,CAAM,GAEhE,EAAE,kBAAAG,EAAqB,IAAA,MAAMC,EAAUH,CAAM;AAEnD,MAAI,CAACE;AAAwB,UAAA,IAAI,MAAM,8BAA8B;AAErE,QAAME,IAAeH,EAAK,QAAQD,GAAQ,aAAa;AACvD,SAAOK,EAAG,aAAaD,GAAc,EAAE,UAAU,SAAS;AAC5D;"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=get-status.cjs.map
@@ -0,0 +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\n\nconst statAsync = promisify(fs.stat);\n\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 ? JSON.parse(readFileSync(metaDataPath, 'utf-8')) : undefined,\n };\n\n return result;\n}\n"],"names":["statAsync","promisify","fs","getStatus","tplDir","markdownPath","path","isTemplateExists","metaDataPath","isMetaDataFileExists","readFileSync"],"mappings":"0IAKMA,EAAYC,EAAU,UAAAC,EAAG,IAAI,EAQnC,eAAsBC,EAAUC,EAA4C,CAC1E,MAAMC,EAAeC,EAAK,QAAQF,EAAQ,aAAa,EAEjDG,GADkB,MAAMP,EAAUK,CAAY,GACX,SAEnCG,EAAeF,EAAK,QAAQF,EAAQ,WAAW,EAE/CK,GADsB,MAAMT,EAAUQ,CAAY,GACP,SAO1C,MAL2B,CAChC,iBAAAD,EACA,KAAME,EAAuB,KAAK,MAAMC,eAAaF,EAAc,OAAO,CAAC,EAAI,MAAA,CAInF"}
@@ -0,0 +1,8 @@
1
+ type TemplateDirStatus = {
2
+ isTemplateExists: boolean;
3
+ meta?: {
4
+ [key: string]: string;
5
+ };
6
+ };
7
+ export declare function getStatus(tplDir: string): Promise<TemplateDirStatus>;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import n, { readFileSync as m } from "fs";
2
+ import s from "path";
3
+ import { promisify as c } from "util";
4
+ const o = c(n.stat);
5
+ async function w(t) {
6
+ const e = s.resolve(t, "template.md"), r = (await o(e)).isFile(), a = s.resolve(t, "meta.json"), i = (await o(a)).isFile();
7
+ return {
8
+ isTemplateExists: r,
9
+ meta: i ? JSON.parse(m(a, "utf-8")) : void 0
10
+ };
11
+ }
12
+ export {
13
+ w as getStatus
14
+ };
15
+ //# sourceMappingURL=get-status.js.map
@@ -0,0 +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\n\nconst statAsync = promisify(fs.stat);\n\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 ? JSON.parse(readFileSync(metaDataPath, 'utf-8')) : undefined,\n };\n\n return result;\n}\n"],"names":["statAsync","promisify","fs","getStatus","tplDir","markdownPath","path","isTemplateExists","metaDataPath","isMetaDataFileExists","readFileSync"],"mappings":";;;AAKA,MAAMA,IAAYC,EAAUC,EAAG,IAAI;AAQnC,eAAsBC,EAAUC,GAA4C;AAC1E,QAAMC,IAAeC,EAAK,QAAQF,GAAQ,aAAa,GAEjDG,KADkB,MAAMP,EAAUK,CAAY,GACX,UAEnCG,IAAeF,EAAK,QAAQF,GAAQ,WAAW,GAE/CK,KADsB,MAAMT,EAAUQ,CAAY,GACP;AAO1C,SAL2B;AAAA,IAChC,kBAAAD;AAAA,IACA,MAAME,IAAuB,KAAK,MAAMC,EAAaF,GAAc,OAAO,CAAC,IAAI;AAAA,EAAA;AAInF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./get-markdown.cjs"),e=require("./scan.cjs"),l=require("./validate-all-locales.cjs"),t=require("./validate-growi-plugin-directive.cjs");exports.getMarkdown=a.getMarkdown;exports.scanAllTemplates=e.scanAllTemplates;exports.scanTemplate=e.scanTemplate;exports.validateAllTemplateLocales=l.validateAllTemplateLocales;exports.validateTemplatePluginGrowiDirective=t.validateTemplatePluginGrowiDirective;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from './get-markdown';
2
+ export * from './scan';
3
+ export * from './validate-all-locales';
4
+ export * from './validate-growi-plugin-directive';
@@ -0,0 +1,12 @@
1
+ import { getMarkdown as l } from "./get-markdown.js";
2
+ import { scanAllTemplates as o, scanTemplate as r } from "./scan.js";
3
+ import { validateAllTemplateLocales as p } from "./validate-all-locales.js";
4
+ import { validateTemplatePluginGrowiDirective as c } from "./validate-growi-plugin-directive.js";
5
+ export {
6
+ l as getMarkdown,
7
+ o as scanAllTemplates,
8
+ r as scanTemplate,
9
+ p as validateAllTemplateLocales,
10
+ c as validateTemplatePluginGrowiDirective
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=scan.cjs.map
@@ -0,0 +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 { isTemplateStatusValid, type TemplateStatus, type TemplateSummary } from '../../../interfaces';\n\nimport { getStatus } from './get-status';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\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 {\n isTemplateExists, meta,\n } = 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) 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 }\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`, { status });\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\n const data = 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 = (await scanTemplate(projectDirRoot, templateId, data, { pluginId: opts?.pluginId }))\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(s => 'isDefault' in s && s.isDefault);\n\n if (defaultTemplateStatus == null || !isTemplateStatusValid(defaultTemplateStatus)) {\n continue;\n }\n\n summaries.push({\n // for the 'default' key\n default: defaultTemplateStatus,\n // for each locale keys\n ...Object.fromEntries(status.map(templateStatus => [templateStatus.locale, templateStatus])),\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":"uPAUaA,EAAe,MACxBC,EACAC,EACAC,EACAC,IAG4B,CAC9B,MAAMC,EAA2B,CAAA,EAE3BC,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,YAAUF,CAAM,EAC9B,CACJ,iBAAAG,EAAkB,KAAAC,CAChB,EAAAH,EAEJ,GAAI,CAACE,EAAwB,MAAA,IAAI,MAAM,8BAA8B,EACrE,GAAIC,GAAQ,KAAY,MAAA,IAAI,MAAM,0BAA0B,EAC5D,IAAIA,GAAA,YAAAA,EAAM,QAAS,KAAY,MAAA,IAAI,MAAM,sCAAsC,EAE/E,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,SAEbQ,EAAK,CACVX,EAAO,KAAK,CACV,SAAUD,GAAA,YAAAA,EAAM,SAChB,GAAIF,EACJ,OAAAO,EACA,QAAS,GACT,cAAgBO,EAAc,OAAA,CAC/B,CACH,CACF,CAGA,eAAQ,MAAM,uBAAuBf,CAAc,gBAAiB,CAAE,OAAAI,EAAQ,EAEvEA,CACT,EAEaY,EAAmB,MAC5BhB,EACAG,IAK6B,CAE/B,MAAMD,GAAOC,GAAA,YAAAA,EAAM,OAAQc,EAAA,qCAAqCjB,CAAc,EAExEkB,EAA+B,CAAA,EAE/BC,EAAcb,EAAK,QAAQN,EAAgB,MAAM,EACjDoB,EAAeC,EAAG,YAAYF,CAAW,EAE/C,gBAAiBlB,KAAcmB,EAAc,CAC3C,MAAMhB,GAAU,MAAML,EAAaC,EAAgBC,EAAYC,EAAM,CAAE,SAAUC,GAAA,YAAAA,EAAM,QAAS,CAAC,GAE9F,OAAOmB,GAAMnB,GAAA,MAAAA,EAAM,wBAA0B,GAAOmB,EAAE,OAAQ,EAG3DC,EAAwBnB,EAAO,QAAU,cAAekB,GAAKA,EAAE,SAAS,EAE1EC,GAAyB,MAAQ,CAACC,EAAA,sBAAsBD,CAAqB,GAIjFL,EAAU,KAAK,CAEb,QAASK,EAET,GAAG,OAAO,YAAYnB,EAAO,IAAsBqB,GAAA,CAACA,EAAe,OAAQA,CAAc,CAAC,CAAC,CAAA,CAC5F,CACH,CAEO,OAAAP,CACT"}
@@ -0,0 +1,11 @@
1
+ import { TemplateStatus, TemplateSummary } from '../../../interfaces';
2
+ import { GrowiTemplatePluginValidationData } from '../../../../model';
3
+
4
+ export declare const scanTemplate: (projectDirRoot: string, templateId: string, data: GrowiTemplatePluginValidationData, opts?: {
5
+ pluginId?: string;
6
+ }) => Promise<TemplateStatus[]>;
7
+ export declare const scanAllTemplates: (projectDirRoot: string, opts?: {
8
+ data?: GrowiTemplatePluginValidationData;
9
+ pluginId?: string;
10
+ returnsInvalidTemplates?: boolean;
11
+ }) => Promise<TemplateSummary[]>;
@@ -0,0 +1,60 @@
1
+ import h from "fs";
2
+ import o from "path";
3
+ import { isTemplateStatusValid as g } from "../../../interfaces/template.js";
4
+ import { getStatus as w } from "./get-status.js";
5
+ import { validateTemplatePluginGrowiDirective as T } from "./validate-growi-plugin-directive.js";
6
+ const v = async (a, e, u, i) => {
7
+ const l = [], c = o.resolve(a, "dist", e);
8
+ let d = !1;
9
+ for await (const n of u.supportingLocales) {
10
+ const r = o.resolve(c, n);
11
+ try {
12
+ const t = await w(r), {
13
+ isTemplateExists: m,
14
+ meta: s
15
+ } = t;
16
+ if (!m)
17
+ throw new Error("'template.md does not exist.");
18
+ if (s == null)
19
+ throw new Error("'meta.md does not exist.");
20
+ if ((s == null ? void 0 : s.title) == null)
21
+ throw new Error("'meta.md does not contain the title.");
22
+ const f = !d;
23
+ l.push({
24
+ pluginId: i == null ? void 0 : i.pluginId,
25
+ id: e,
26
+ locale: n,
27
+ isValid: !0,
28
+ isDefault: f,
29
+ title: s.title,
30
+ desc: s.desc
31
+ }), d = !0;
32
+ } catch (t) {
33
+ l.push({
34
+ pluginId: i == null ? void 0 : i.pluginId,
35
+ id: e,
36
+ locale: n,
37
+ isValid: !1,
38
+ invalidReason: t.message
39
+ });
40
+ }
41
+ }
42
+ return console.debug(`Template directory (${a}) has scanned`, { status: l }), l;
43
+ }, P = async (a, e) => {
44
+ const u = (e == null ? void 0 : e.data) ?? T(a), i = [], l = o.resolve(a, "dist"), c = h.readdirSync(l);
45
+ for await (const d of c) {
46
+ const n = (await v(a, d, u, { 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);
47
+ r == null || !g(r) || i.push({
48
+ // for the 'default' key
49
+ default: r,
50
+ // for each locale keys
51
+ ...Object.fromEntries(n.map((t) => [t.locale, t]))
52
+ });
53
+ }
54
+ return i;
55
+ };
56
+ export {
57
+ P as scanAllTemplates,
58
+ v as scanTemplate
59
+ };
60
+ //# sourceMappingURL=scan.js.map
@@ -0,0 +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 { isTemplateStatusValid, type TemplateStatus, type TemplateSummary } from '../../../interfaces';\n\nimport { getStatus } from './get-status';\nimport { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';\n\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 {\n isTemplateExists, meta,\n } = 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) 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 }\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`, { status });\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\n const data = 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 = (await scanTemplate(projectDirRoot, templateId, data, { pluginId: opts?.pluginId }))\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(s => 'isDefault' in s && s.isDefault);\n\n if (defaultTemplateStatus == null || !isTemplateStatusValid(defaultTemplateStatus)) {\n continue;\n }\n\n summaries.push({\n // for the 'default' key\n default: defaultTemplateStatus,\n // for each locale keys\n ...Object.fromEntries(status.map(templateStatus => [templateStatus.locale, templateStatus])),\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":";;;;;AAUO,MAAMA,IAAe,OACxBC,GACAC,GACAC,GACAC,MAG4B;AAC9B,QAAMC,IAA2B,CAAA,GAE3BC,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;AAAA,QACJ,kBAAAG;AAAA,QAAkB,MAAAC;AAAA,MAChB,IAAAH;AAEJ,UAAI,CAACE;AAAwB,cAAA,IAAI,MAAM,8BAA8B;AACrE,UAAIC,KAAQ;AAAY,cAAA,IAAI,MAAM,0BAA0B;AAC5D,WAAIA,KAAA,gBAAAA,EAAM,UAAS;AAAY,cAAA,IAAI,MAAM,sCAAsC;AAE/E,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,aAEbQ,GAAK;AACV,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,IACH;AAAA,EACF;AAGA,iBAAQ,MAAM,uBAAuBf,CAAc,iBAAiB,EAAE,QAAAI,GAAQ,GAEvEA;AACT,GAEaY,IAAmB,OAC5BhB,GACAG,MAK6B;AAE/B,QAAMD,KAAOC,KAAA,gBAAAA,EAAM,SAAQc,EAAqCjB,CAAc,GAExEkB,IAA+B,CAAA,GAE/BC,IAAcb,EAAK,QAAQN,GAAgB,MAAM,GACjDoB,IAAeC,EAAG,YAAYF,CAAW;AAE/C,mBAAiBlB,KAAcmB,GAAc;AAC3C,UAAMhB,KAAU,MAAML,EAAaC,GAAgBC,GAAYC,GAAM,EAAE,UAAUC,KAAA,gBAAAA,EAAM,SAAS,CAAC,GAE9F,OAAO,CAAAmB,MAAMnB,KAAA,QAAAA,EAAM,0BAA0B,KAAOmB,EAAE,OAAQ,GAG3DC,IAAwBnB,EAAO,KAAK,OAAK,eAAekB,KAAKA,EAAE,SAAS;AAE9E,IAAIC,KAAyB,QAAQ,CAACC,EAAsBD,CAAqB,KAIjFL,EAAU,KAAK;AAAA;AAAA,MAEb,SAASK;AAAA;AAAA,MAET,GAAG,OAAO,YAAYnB,EAAO,IAAI,CAAkBqB,MAAA,CAACA,EAAe,QAAQA,CAAc,CAAC,CAAC;AAAA,IAAA,CAC5F;AAAA,EACH;AAEO,SAAAP;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./scan.cjs"),o=require("./validate-growi-plugin-directive.cjs"),c=async l=>{const n=o.validateTemplatePluginGrowiDirective(l),i=await r.scanAllTemplates(l,{data:n,returnsInvalidTemplates:!0});if(Object.keys(i).length===0)throw new Error("This plugin does not have any templates");const s={};i.forEach(a=>{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
+ //# sourceMappingURL=validate-all-locales.cjs.map
@@ -0,0 +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\n\nexport const validateAllTemplateLocales = async(projectDirRoot: string): Promise<boolean> => {\n const data = validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const results = await scanAllTemplates(projectDirRoot, { data, returnsInvalidTemplates: true });\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 results.forEach((summary) => {\n idValidMap[summary.default.id] = Object.values(summary).map(s => s?.isValid ?? false);\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(`[WARN] Template '${id}' has some locales that status is invalid`);\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":"iKAIaA,EAA6B,MAAMC,GAA6C,CACrF,MAAAC,EAAOC,uCAAqCF,CAAc,EAE1DG,EAAU,MAAMC,EAAAA,iBAAiBJ,EAAgB,CAAE,KAAAC,EAAM,wBAAyB,GAAM,EAE9F,GAAI,OAAO,KAAKE,CAAO,EAAE,SAAW,EAC5B,MAAA,IAAI,MAAM,yCAAyC,EAM3D,MAAME,EAA0C,CAAA,EACxCF,EAAA,QAASG,GAAY,CAC3BD,EAAWC,EAAQ,QAAQ,EAAE,EAAI,OAAO,OAAOA,CAAO,EAAE,IAAIC,IAAKA,GAAA,YAAAA,EAAG,UAAW,EAAK,CAAA,CACrF,EAED,SAAW,CAACC,EAAIC,CAAQ,IAAK,OAAO,QAAQJ,CAAU,EAQpD,GANKI,EAAS,MAAMC,GAAQA,CAAI,GAEtB,QAAA,KAAK,oBAAoBF,CAAE,2CAA2C,EAI5E,CAACC,EAAS,KAAKC,GAAQA,CAAI,EACtB,MAAA,GAIJ,MAAA,EACT"}
@@ -0,0 +1 @@
1
+ export declare const validateAllTemplateLocales: (projectDirRoot: string) => Promise<boolean>;
@@ -0,0 +1,19 @@
1
+ import { scanAllTemplates as n } from "./scan.js";
2
+ import { validateTemplatePluginGrowiDirective as o } from "./validate-growi-plugin-directive.js";
3
+ const p = async (l) => {
4
+ const r = o(l), i = await n(l, { data: r, returnsInvalidTemplates: !0 });
5
+ if (Object.keys(i).length === 0)
6
+ throw new Error("This plugin does not have any templates");
7
+ const s = {};
8
+ i.forEach((a) => {
9
+ s[a.default.id] = Object.values(a).map((e) => (e == null ? void 0 : e.isValid) ?? !1);
10
+ });
11
+ for (const [a, e] of Object.entries(s))
12
+ if (e.every((t) => t) || console.warn(`[WARN] Template '${a}' has some locales that status is invalid`), !e.some((t) => t))
13
+ return !1;
14
+ return !0;
15
+ };
16
+ export {
17
+ p as validateAllTemplateLocales
18
+ };
19
+ //# sourceMappingURL=validate-all-locales.js.map
@@ -0,0 +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\n\nexport const validateAllTemplateLocales = async(projectDirRoot: string): Promise<boolean> => {\n const data = validateTemplatePluginGrowiDirective(projectDirRoot);\n\n const results = await scanAllTemplates(projectDirRoot, { data, returnsInvalidTemplates: true });\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 results.forEach((summary) => {\n idValidMap[summary.default.id] = Object.values(summary).map(s => s?.isValid ?? false);\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(`[WARN] Template '${id}' has some locales that status is invalid`);\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":";;AAIa,MAAAA,IAA6B,OAAMC,MAA6C;AACrF,QAAAC,IAAOC,EAAqCF,CAAc,GAE1DG,IAAU,MAAMC,EAAiBJ,GAAgB,EAAE,MAAAC,GAAM,yBAAyB,IAAM;AAE9F,MAAI,OAAO,KAAKE,CAAO,EAAE,WAAW;AAC5B,UAAA,IAAI,MAAM,yCAAyC;AAM3D,QAAME,IAA0C,CAAA;AACxC,EAAAF,EAAA,QAAQ,CAACG,MAAY;AAC3B,IAAAD,EAAWC,EAAQ,QAAQ,EAAE,IAAI,OAAO,OAAOA,CAAO,EAAE,IAAI,CAAAC,OAAKA,KAAA,gBAAAA,EAAG,YAAW,EAAK;AAAA,EAAA,CACrF;AAED,aAAW,CAACC,GAAIC,CAAQ,KAAK,OAAO,QAAQJ,CAAU;AAQpD,QANKI,EAAS,MAAM,CAAAC,MAAQA,CAAI,KAEtB,QAAA,KAAK,oBAAoBF,CAAE,2CAA2C,GAI5E,CAACC,EAAS,KAAK,CAAAC,MAAQA,CAAI;AACtB,aAAA;AAIJ,SAAA;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@growi/core"),l=require("../../../../model/growi-plugin-validation-error.cjs"),a=require("../common/validate-growi-plugin-directive.cjs"),n=t=>{const i=a.validateGrowiDirective(t,o.GrowiPluginType.Template),{growiPlugin:r}=i,e=r.locales;if(e==null||e.length===0)throw new l.GrowiPluginValidationError("Template plugin must have 'supportingLocales' and that must have one or more locales",{...i,supportingLocales:e});return{...i,supportingLocales:e}};exports.validateTemplatePluginGrowiDirective=n;
2
+ //# sourceMappingURL=validate-growi-plugin-directive.cjs.map
@@ -0,0 +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 { GrowiPluginValidationData, GrowiTemplatePluginValidationData } from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n\n/**\n * An utility for template plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateTemplatePluginGrowiDirective = (projectDirRoot: string): 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<GrowiPluginValidationData & { supportingLocales?: string[] }>(\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":"2OAWaA,EAAwCC,GAA8D,CACjH,MAAMC,EAAOC,EAAA,uBAAuBF,EAAgBG,EAAA,gBAAgB,QAAQ,EAEtE,CAAE,YAAAC,CAAgB,EAAAH,EAGlBI,EAA0CD,EAAY,QAC5D,GAAIC,GAAqB,MAAQA,EAAkB,SAAW,EAC5D,MAAM,IAAIC,EAAA,2BACR,uFACA,CACE,GAAGL,EACH,kBAAAI,CACF,CAAA,EAIG,MAAA,CACL,GAAGJ,EACH,kBAAAI,CAAA,CAEJ"}
@@ -0,0 +1,7 @@
1
+ import { GrowiTemplatePluginValidationData } from '../../../../model';
2
+
3
+ /**
4
+ * An utility for template plugin which wrap 'validateGrowiDirective' of './common' module
5
+ * @param projectDirRoot
6
+ */
7
+ export declare const validateTemplatePluginGrowiDirective: (projectDirRoot: string) => GrowiTemplatePluginValidationData;
@@ -0,0 +1,22 @@
1
+ import { GrowiPluginType as r } from "@growi/core";
2
+ import { GrowiPluginValidationError as l } from "../../../../model/growi-plugin-validation-error.js";
3
+ import { validateGrowiDirective as a } from "../common/validate-growi-plugin-directive.js";
4
+ const s = (e) => {
5
+ const t = a(e, r.Template), { growiPlugin: i } = t, o = i.locales;
6
+ if (o == null || o.length === 0)
7
+ throw new l(
8
+ "Template plugin must have 'supportingLocales' and that must have one or more locales",
9
+ {
10
+ ...t,
11
+ supportingLocales: o
12
+ }
13
+ );
14
+ return {
15
+ ...t,
16
+ supportingLocales: o
17
+ };
18
+ };
19
+ export {
20
+ s as validateTemplatePluginGrowiDirective
21
+ };
22
+ //# sourceMappingURL=validate-growi-plugin-directive.js.map
@@ -0,0 +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 { GrowiPluginValidationData, GrowiTemplatePluginValidationData } from '../../../../model';\nimport { GrowiPluginValidationError } from '../../../../model';\nimport { validateGrowiDirective } from '../common';\n\n\n/**\n * An utility for template plugin which wrap 'validateGrowiDirective' of './common' module\n * @param projectDirRoot\n */\nexport const validateTemplatePluginGrowiDirective = (projectDirRoot: string): 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<GrowiPluginValidationData & { supportingLocales?: string[] }>(\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":";;;AAWa,MAAAA,IAAuC,CAACC,MAA8D;AACjH,QAAMC,IAAOC,EAAuBF,GAAgBG,EAAgB,QAAQ,GAEtE,EAAE,aAAAC,EAAgB,IAAAH,GAGlBI,IAA0CD,EAAY;AAC5D,MAAIC,KAAqB,QAAQA,EAAkB,WAAW;AAC5D,UAAM,IAAIC;AAAA,MACR;AAAA,MACA;AAAA,QACE,GAAGL;AAAA,QACH,mBAAAI;AAAA,MACF;AAAA,IAAA;AAIG,SAAA;AAAA,IACL,GAAGJ;AAAA,IACH,mBAAAI;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./template.cjs");exports.extractSupportedLocales=e.extractSupportedLocales;exports.getLocalizedTemplate=e.getLocalizedTemplate;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './template';
@@ -0,0 +1,6 @@
1
+ import { extractSupportedLocales as o, getLocalizedTemplate as a } from "./template.js";
2
+ export {
3
+ o as extractSupportedLocales,
4
+ a as getLocalizedTemplate
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=(e,t)=>{if(e!=null)return t!=null&&t in e?e[t]:e.default},o=e=>{if(e!=null)return new Set(Object.values(e).map(t=>t.locale))};exports.extractSupportedLocales=o;exports.getLocalizedTemplate=n;
2
+ //# sourceMappingURL=template.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.cjs","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type { TemplateSummary, TemplateStatus } from '../interfaces';\n\nexport const getLocalizedTemplate = (templateSummary: TemplateSummary | undefined, locale?: string): 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 = (templateSummary: TemplateSummary | undefined): 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,CAACC,EAA8CC,IAAgD,CACjI,GAAID,GAAmB,KAIvB,OAAOC,GAAU,MAAQA,KAAUD,EAC/BA,EAAgBC,CAAM,EACtBD,EAAgB,OACtB,EAEaE,EAA2BF,GAA0E,CAChH,GAAIA,GAAmB,KAIhB,OAAA,IAAI,IAAI,OAAO,OAAOA,CAAe,EAAE,IAAIG,GAAKA,EAAE,MAAM,CAAC,CAClE"}
@@ -0,0 +1,4 @@
1
+ import { TemplateSummary, TemplateStatus } from '../interfaces';
2
+
3
+ export declare const getLocalizedTemplate: (templateSummary: TemplateSummary | undefined, locale?: string) => TemplateStatus | undefined;
4
+ export declare const extractSupportedLocales: (templateSummary: TemplateSummary | undefined) => Set<string> | undefined;
@@ -0,0 +1,12 @@
1
+ const o = (n, e) => {
2
+ if (n != null)
3
+ return e != null && e in n ? n[e] : n.default;
4
+ }, r = (n) => {
5
+ if (n != null)
6
+ return new Set(Object.values(n).map((e) => e.locale));
7
+ };
8
+ export {
9
+ r as extractSupportedLocales,
10
+ o as getLocalizedTemplate
11
+ };
12
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sources":["../../../src/v4/utils/template.ts"],"sourcesContent":["import type { TemplateSummary, TemplateStatus } from '../interfaces';\n\nexport const getLocalizedTemplate = (templateSummary: TemplateSummary | undefined, locale?: string): 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 = (templateSummary: TemplateSummary | undefined): 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,CAACC,GAA8CC,MAAgD;AACjI,MAAID,KAAmB;AAIvB,WAAOC,KAAU,QAAQA,KAAUD,IAC/BA,EAAgBC,CAAM,IACtBD,EAAgB;AACtB,GAEaE,IAA0B,CAACF,MAA0E;AAChH,MAAIA,KAAmB;AAIhB,WAAA,IAAI,IAAI,OAAO,OAAOA,CAAe,EAAE,IAAI,CAAAG,MAAKA,EAAE,MAAM,CAAC;AAClE;"}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@growi/pluginkit",
3
+ "version": "1.0.0-next.0",
4
+ "description": "Plugin kit for GROWI",
5
+ "license": "MIT",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "type": "module",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "vite build",
15
+ "clean": "shx rm -rf dist",
16
+ "dev": "vite build --mode dev",
17
+ "watch": "yarn dev -w --emptyOutDir=false",
18
+ "lint:js": "yarn eslint **/*.{js,ts}",
19
+ "lint:typecheck": "tsc",
20
+ "lint": "npm-run-all -p lint:*",
21
+ "test": "vitest run --coverage"
22
+ },
23
+ "dependencies": {
24
+ "@growi/core": "^1.0.0-next.0",
25
+ "extensible-custom-error": "^0.0.7"
26
+ },
27
+ "devDependencies": {}
28
+ }