@sitecore-content-sdk/core 0.1.0-beta.16 → 0.1.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tools/index.js +15 -0
- package/dist/cjs/tools/templating/components.js +26 -0
- package/dist/cjs/tools/templating/index.js +8 -0
- package/dist/cjs/tools/templating/plugins.js +78 -0
- package/dist/cjs/tools/templating/utils.js +42 -0
- package/dist/esm/tools/index.js +1 -0
- package/dist/esm/tools/templating/components.js +23 -0
- package/dist/esm/tools/templating/index.js +2 -0
- package/dist/esm/tools/templating/plugins.js +70 -0
- package/dist/esm/tools/templating/utils.js +36 -0
- package/package.json +2 -2
- package/types/tools/index.d.ts +1 -0
- package/types/tools/templating/components.d.ts +29 -0
- package/types/tools/templating/index.d.ts +2 -0
- package/types/tools/templating/plugins.d.ts +67 -0
- package/types/tools/templating/utils.d.ts +32 -0
package/dist/cjs/tools/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.scaffoldComponent = exports.generateMetadata = exports.generateSites = void 0;
|
|
4
18
|
var generateSites_1 = require("./generateSites");
|
|
@@ -7,3 +21,4 @@ var generateMetadata_1 = require("./generateMetadata");
|
|
|
7
21
|
Object.defineProperty(exports, "generateMetadata", { enumerable: true, get: function () { return generateMetadata_1.generateMetadata; } });
|
|
8
22
|
var scaffold_1 = require("./scaffold");
|
|
9
23
|
Object.defineProperty(exports, "scaffoldComponent", { enumerable: true, get: function () { return scaffold_1.scaffoldComponent; } });
|
|
24
|
+
__exportStar(require("./templating"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getComponentList = getComponentList;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
/**
|
|
6
|
+
* Get list of components from @var path
|
|
7
|
+
* Returns a list of components in the following format:
|
|
8
|
+
* {
|
|
9
|
+
* path: 'path/to/component',
|
|
10
|
+
* componentName: 'ComponentName',
|
|
11
|
+
* moduleName: 'ComponentName'
|
|
12
|
+
* }
|
|
13
|
+
* @param {string} path path to search
|
|
14
|
+
*/
|
|
15
|
+
function getComponentList(path) {
|
|
16
|
+
const components = (0, utils_1.getItems)({
|
|
17
|
+
path,
|
|
18
|
+
resolveItem: (path, name) => ({
|
|
19
|
+
path: `${path}/${name}`,
|
|
20
|
+
componentName: name,
|
|
21
|
+
moduleName: name.replace(/[^\w]+/g, ''),
|
|
22
|
+
}),
|
|
23
|
+
cb: (name) => console.debug(`Registering JSS component ${name}`),
|
|
24
|
+
});
|
|
25
|
+
return components;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleType = exports.generatePlugins = exports.getComponentList = void 0;
|
|
4
|
+
var components_1 = require("./components");
|
|
5
|
+
Object.defineProperty(exports, "getComponentList", { enumerable: true, get: function () { return components_1.getComponentList; } });
|
|
6
|
+
var plugins_1 = require("./plugins");
|
|
7
|
+
Object.defineProperty(exports, "generatePlugins", { enumerable: true, get: function () { return plugins_1.generatePlugins; } });
|
|
8
|
+
Object.defineProperty(exports, "ModuleType", { enumerable: true, get: function () { return plugins_1.ModuleType; } });
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ModuleType = void 0;
|
|
7
|
+
exports.getPluginList = getPluginList;
|
|
8
|
+
exports.generatePlugins = generatePlugins;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
/**
|
|
13
|
+
* Identifies the format of the module to be compiled
|
|
14
|
+
*/
|
|
15
|
+
var ModuleType;
|
|
16
|
+
(function (ModuleType) {
|
|
17
|
+
ModuleType[ModuleType["CJS"] = 0] = "CJS";
|
|
18
|
+
ModuleType[ModuleType["ESM"] = 1] = "ESM";
|
|
19
|
+
})(ModuleType || (exports.ModuleType = ModuleType = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Get list of plugins from @var path
|
|
22
|
+
* Returns a list of plugins in the following format:
|
|
23
|
+
* {
|
|
24
|
+
* path: 'path/to/plugin/foo',
|
|
25
|
+
* name: 'fooPlugin'
|
|
26
|
+
* }
|
|
27
|
+
* @example getPluginList('src/foo/plugins', 'Foo')
|
|
28
|
+
* @param {object} definition plugin definition
|
|
29
|
+
* @param {string} definition.path path to get plugin from
|
|
30
|
+
* @param {string} definition.pluginName plugin name
|
|
31
|
+
* @param {boolean} [definition.silent] whether to suppress console output
|
|
32
|
+
*/
|
|
33
|
+
function getPluginList({ path, pluginName, silent = false, }) {
|
|
34
|
+
const plugins = (0, utils_1.getItems)({
|
|
35
|
+
path,
|
|
36
|
+
resolveItem: (path, name) => ({
|
|
37
|
+
path: `${path}/${name}`,
|
|
38
|
+
name: `${name.replace(/-./g, (x) => x[1].toUpperCase())}Plugin`,
|
|
39
|
+
}),
|
|
40
|
+
cb: (name) => !silent && console.debug(`Registering ${pluginName} plugin ${name}`),
|
|
41
|
+
});
|
|
42
|
+
return plugins;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generates the plugins file and saves it to the filesystem.
|
|
46
|
+
* By convention, we expect to find plugins under {pluginName}/plugins/** (subfolders are searched recursively).
|
|
47
|
+
* generated file will be saved to @var {distPath} and will contain a list of plugins in the following format:
|
|
48
|
+
* CJS: exports.fooPlugin = require('{pluginPath}');
|
|
49
|
+
* ESM: export { fooPlugin } from '{pluginPath}';
|
|
50
|
+
* @example generatePlugins({ distPath: 'src/temp/foo-plugins.js', rootPath: 'src/foo/plugins', moduleType: ModuleType.CJS })
|
|
51
|
+
* @param {PluginDefinition} definition plugin definition
|
|
52
|
+
*/
|
|
53
|
+
function generatePlugins(definition) {
|
|
54
|
+
const { rootPath, distPath, moduleType, relative = false, silent } = definition;
|
|
55
|
+
const segments = rootPath.split('/');
|
|
56
|
+
const pluginName = segments[segments.length - 2];
|
|
57
|
+
const plugins = getPluginList({ path: rootPath, pluginName, silent });
|
|
58
|
+
let fileContent = '';
|
|
59
|
+
fileContent = plugins
|
|
60
|
+
.map((plugin) => {
|
|
61
|
+
const sourcePath = relative
|
|
62
|
+
? path_1.default.relative(path_1.default.dirname(distPath), plugin.path).replace(/\\/g, '/')
|
|
63
|
+
: plugin.path;
|
|
64
|
+
return moduleType === ModuleType.CJS
|
|
65
|
+
? `exports.${plugin.name} = require('${sourcePath}');`
|
|
66
|
+
: `export { ${plugin.name} } from '${sourcePath}';`;
|
|
67
|
+
})
|
|
68
|
+
.join('\r\n')
|
|
69
|
+
.concat('\r\n');
|
|
70
|
+
if (!plugins.length) {
|
|
71
|
+
fileContent = moduleType === ModuleType.CJS ? 'module.exports = {};\r\n' : 'export {};\r\n';
|
|
72
|
+
}
|
|
73
|
+
const filePath = path_1.default.resolve(distPath);
|
|
74
|
+
!silent && console.log(`Writing ${pluginName} plugins to ${filePath}`);
|
|
75
|
+
fs_1.default.writeFileSync(filePath, fileContent, {
|
|
76
|
+
encoding: 'utf8',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getItems = getItems;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
/**
|
|
9
|
+
* Using @var path find all files and generate output using @var resolveItem function for each file
|
|
10
|
+
* Can be used to generate list of components, templates, etc.
|
|
11
|
+
* @param {GetItemsSettings} settings
|
|
12
|
+
* @returns {Item[]} list of items
|
|
13
|
+
*/
|
|
14
|
+
function getItems(settings) {
|
|
15
|
+
const { recursive = true, path, resolveItem, cb, fileFormat = new RegExp(/(.+)(?<!\.d)\.[jt]sx?$/), } = settings;
|
|
16
|
+
const items = [];
|
|
17
|
+
const folders = [];
|
|
18
|
+
if (!fs_1.default.existsSync(path))
|
|
19
|
+
return [];
|
|
20
|
+
fs_1.default.readdirSync(path, { withFileTypes: true }).forEach((item) => {
|
|
21
|
+
if (item.isDirectory()) {
|
|
22
|
+
folders.push(item);
|
|
23
|
+
}
|
|
24
|
+
if (fileFormat.test(item.name)) {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
+
const name = item.name.match(fileFormat)[1];
|
|
27
|
+
items.push(resolveItem(path, name));
|
|
28
|
+
cb && cb(name);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
for (const folder of folders) {
|
|
32
|
+
recursive
|
|
33
|
+
? items.push(...getItems({
|
|
34
|
+
path: `${path}/${folder.name}`,
|
|
35
|
+
resolveItem,
|
|
36
|
+
cb,
|
|
37
|
+
fileFormat,
|
|
38
|
+
}))
|
|
39
|
+
: items.push(resolveItem(`${path}/${folder.name}`, folder.name));
|
|
40
|
+
}
|
|
41
|
+
return items;
|
|
42
|
+
}
|
package/dist/esm/tools/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getItems } from './utils';
|
|
2
|
+
/**
|
|
3
|
+
* Get list of components from @var path
|
|
4
|
+
* Returns a list of components in the following format:
|
|
5
|
+
* {
|
|
6
|
+
* path: 'path/to/component',
|
|
7
|
+
* componentName: 'ComponentName',
|
|
8
|
+
* moduleName: 'ComponentName'
|
|
9
|
+
* }
|
|
10
|
+
* @param {string} path path to search
|
|
11
|
+
*/
|
|
12
|
+
export function getComponentList(path) {
|
|
13
|
+
const components = getItems({
|
|
14
|
+
path,
|
|
15
|
+
resolveItem: (path, name) => ({
|
|
16
|
+
path: `${path}/${name}`,
|
|
17
|
+
componentName: name,
|
|
18
|
+
moduleName: name.replace(/[^\w]+/g, ''),
|
|
19
|
+
}),
|
|
20
|
+
cb: (name) => console.debug(`Registering JSS component ${name}`),
|
|
21
|
+
});
|
|
22
|
+
return components;
|
|
23
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getItems } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the format of the module to be compiled
|
|
6
|
+
*/
|
|
7
|
+
export var ModuleType;
|
|
8
|
+
(function (ModuleType) {
|
|
9
|
+
ModuleType[ModuleType["CJS"] = 0] = "CJS";
|
|
10
|
+
ModuleType[ModuleType["ESM"] = 1] = "ESM";
|
|
11
|
+
})(ModuleType || (ModuleType = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Get list of plugins from @var path
|
|
14
|
+
* Returns a list of plugins in the following format:
|
|
15
|
+
* {
|
|
16
|
+
* path: 'path/to/plugin/foo',
|
|
17
|
+
* name: 'fooPlugin'
|
|
18
|
+
* }
|
|
19
|
+
* @example getPluginList('src/foo/plugins', 'Foo')
|
|
20
|
+
* @param {object} definition plugin definition
|
|
21
|
+
* @param {string} definition.path path to get plugin from
|
|
22
|
+
* @param {string} definition.pluginName plugin name
|
|
23
|
+
* @param {boolean} [definition.silent] whether to suppress console output
|
|
24
|
+
*/
|
|
25
|
+
export function getPluginList({ path, pluginName, silent = false, }) {
|
|
26
|
+
const plugins = getItems({
|
|
27
|
+
path,
|
|
28
|
+
resolveItem: (path, name) => ({
|
|
29
|
+
path: `${path}/${name}`,
|
|
30
|
+
name: `${name.replace(/-./g, (x) => x[1].toUpperCase())}Plugin`,
|
|
31
|
+
}),
|
|
32
|
+
cb: (name) => !silent && console.debug(`Registering ${pluginName} plugin ${name}`),
|
|
33
|
+
});
|
|
34
|
+
return plugins;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generates the plugins file and saves it to the filesystem.
|
|
38
|
+
* By convention, we expect to find plugins under {pluginName}/plugins/** (subfolders are searched recursively).
|
|
39
|
+
* generated file will be saved to @var {distPath} and will contain a list of plugins in the following format:
|
|
40
|
+
* CJS: exports.fooPlugin = require('{pluginPath}');
|
|
41
|
+
* ESM: export { fooPlugin } from '{pluginPath}';
|
|
42
|
+
* @example generatePlugins({ distPath: 'src/temp/foo-plugins.js', rootPath: 'src/foo/plugins', moduleType: ModuleType.CJS })
|
|
43
|
+
* @param {PluginDefinition} definition plugin definition
|
|
44
|
+
*/
|
|
45
|
+
export function generatePlugins(definition) {
|
|
46
|
+
const { rootPath, distPath, moduleType, relative = false, silent } = definition;
|
|
47
|
+
const segments = rootPath.split('/');
|
|
48
|
+
const pluginName = segments[segments.length - 2];
|
|
49
|
+
const plugins = getPluginList({ path: rootPath, pluginName, silent });
|
|
50
|
+
let fileContent = '';
|
|
51
|
+
fileContent = plugins
|
|
52
|
+
.map((plugin) => {
|
|
53
|
+
const sourcePath = relative
|
|
54
|
+
? path.relative(path.dirname(distPath), plugin.path).replace(/\\/g, '/')
|
|
55
|
+
: plugin.path;
|
|
56
|
+
return moduleType === ModuleType.CJS
|
|
57
|
+
? `exports.${plugin.name} = require('${sourcePath}');`
|
|
58
|
+
: `export { ${plugin.name} } from '${sourcePath}';`;
|
|
59
|
+
})
|
|
60
|
+
.join('\r\n')
|
|
61
|
+
.concat('\r\n');
|
|
62
|
+
if (!plugins.length) {
|
|
63
|
+
fileContent = moduleType === ModuleType.CJS ? 'module.exports = {};\r\n' : 'export {};\r\n';
|
|
64
|
+
}
|
|
65
|
+
const filePath = path.resolve(distPath);
|
|
66
|
+
!silent && console.log(`Writing ${pluginName} plugins to ${filePath}`);
|
|
67
|
+
fs.writeFileSync(filePath, fileContent, {
|
|
68
|
+
encoding: 'utf8',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
/**
|
|
3
|
+
* Using @var path find all files and generate output using @var resolveItem function for each file
|
|
4
|
+
* Can be used to generate list of components, templates, etc.
|
|
5
|
+
* @param {GetItemsSettings} settings
|
|
6
|
+
* @returns {Item[]} list of items
|
|
7
|
+
*/
|
|
8
|
+
export function getItems(settings) {
|
|
9
|
+
const { recursive = true, path, resolveItem, cb, fileFormat = new RegExp(/(.+)(?<!\.d)\.[jt]sx?$/), } = settings;
|
|
10
|
+
const items = [];
|
|
11
|
+
const folders = [];
|
|
12
|
+
if (!fs.existsSync(path))
|
|
13
|
+
return [];
|
|
14
|
+
fs.readdirSync(path, { withFileTypes: true }).forEach((item) => {
|
|
15
|
+
if (item.isDirectory()) {
|
|
16
|
+
folders.push(item);
|
|
17
|
+
}
|
|
18
|
+
if (fileFormat.test(item.name)) {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
+
const name = item.name.match(fileFormat)[1];
|
|
21
|
+
items.push(resolveItem(path, name));
|
|
22
|
+
cb && cb(name);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
for (const folder of folders) {
|
|
26
|
+
recursive
|
|
27
|
+
? items.push(...getItems({
|
|
28
|
+
path: `${path}/${folder.name}`,
|
|
29
|
+
resolveItem,
|
|
30
|
+
cb,
|
|
31
|
+
fileFormat,
|
|
32
|
+
}))
|
|
33
|
+
: items.push(resolveItem(`${path}/${folder.name}`, folder.name));
|
|
34
|
+
}
|
|
35
|
+
return items;
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.18",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"description": "",
|
|
69
69
|
"types": "types/index.d.ts",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "1edf1b0efcb6445d6f989542097a419e3410e61f",
|
|
71
71
|
"files": [
|
|
72
72
|
"dist",
|
|
73
73
|
"types",
|
package/types/tools/index.d.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes a file that represents a component definition
|
|
3
|
+
*/
|
|
4
|
+
export interface ComponentFile {
|
|
5
|
+
path: string;
|
|
6
|
+
moduleName: string;
|
|
7
|
+
componentName: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Describes a package and components to be imported
|
|
11
|
+
*/
|
|
12
|
+
export interface PackageDefinition {
|
|
13
|
+
name: string;
|
|
14
|
+
components: {
|
|
15
|
+
moduleName: string;
|
|
16
|
+
componentName: string;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get list of components from @var path
|
|
21
|
+
* Returns a list of components in the following format:
|
|
22
|
+
* {
|
|
23
|
+
* path: 'path/to/component',
|
|
24
|
+
* componentName: 'ComponentName',
|
|
25
|
+
* moduleName: 'ComponentName'
|
|
26
|
+
* }
|
|
27
|
+
* @param {string} path path to search
|
|
28
|
+
*/
|
|
29
|
+
export declare function getComponentList(path: string): ComponentFile[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifies the format of the module to be compiled
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ModuleType {
|
|
5
|
+
CJS = 0,
|
|
6
|
+
ESM = 1
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Type to specify plugin file details
|
|
10
|
+
*/
|
|
11
|
+
export interface PluginFile {
|
|
12
|
+
path: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Definition to be used for plugin registration during bootstrap
|
|
17
|
+
*/
|
|
18
|
+
export interface PluginDefinition {
|
|
19
|
+
/**
|
|
20
|
+
* destination path to compile plugins to
|
|
21
|
+
*/
|
|
22
|
+
distPath: string;
|
|
23
|
+
/**
|
|
24
|
+
* source path for where the plugins are defined
|
|
25
|
+
*/
|
|
26
|
+
rootPath: string;
|
|
27
|
+
/**
|
|
28
|
+
* CJS or ESM - which type to compile plugins to
|
|
29
|
+
*/
|
|
30
|
+
moduleType: ModuleType;
|
|
31
|
+
/**
|
|
32
|
+
* whether to use relative or absolute paths in the generated file. By default, absolute paths are used.
|
|
33
|
+
*/
|
|
34
|
+
relative?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* whether to suppress console output
|
|
37
|
+
*/
|
|
38
|
+
silent?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get list of plugins from @var path
|
|
42
|
+
* Returns a list of plugins in the following format:
|
|
43
|
+
* {
|
|
44
|
+
* path: 'path/to/plugin/foo',
|
|
45
|
+
* name: 'fooPlugin'
|
|
46
|
+
* }
|
|
47
|
+
* @example getPluginList('src/foo/plugins', 'Foo')
|
|
48
|
+
* @param {object} definition plugin definition
|
|
49
|
+
* @param {string} definition.path path to get plugin from
|
|
50
|
+
* @param {string} definition.pluginName plugin name
|
|
51
|
+
* @param {boolean} [definition.silent] whether to suppress console output
|
|
52
|
+
*/
|
|
53
|
+
export declare function getPluginList({ path, pluginName, silent, }: {
|
|
54
|
+
path: string;
|
|
55
|
+
pluginName: string;
|
|
56
|
+
silent?: boolean;
|
|
57
|
+
}): PluginFile[];
|
|
58
|
+
/**
|
|
59
|
+
* Generates the plugins file and saves it to the filesystem.
|
|
60
|
+
* By convention, we expect to find plugins under {pluginName}/plugins/** (subfolders are searched recursively).
|
|
61
|
+
* generated file will be saved to @var {distPath} and will contain a list of plugins in the following format:
|
|
62
|
+
* CJS: exports.fooPlugin = require('{pluginPath}');
|
|
63
|
+
* ESM: export { fooPlugin } from '{pluginPath}';
|
|
64
|
+
* @example generatePlugins({ distPath: 'src/temp/foo-plugins.js', rootPath: 'src/foo/plugins', moduleType: ModuleType.CJS })
|
|
65
|
+
* @param {PluginDefinition} definition plugin definition
|
|
66
|
+
*/
|
|
67
|
+
export declare function generatePlugins(definition: PluginDefinition): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings for @var getItems function
|
|
3
|
+
*/
|
|
4
|
+
export type GetItemsSettings<Item> = {
|
|
5
|
+
/**
|
|
6
|
+
* items path
|
|
7
|
+
*/
|
|
8
|
+
path: string;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve item in required data format
|
|
11
|
+
*/
|
|
12
|
+
resolveItem: (path: string, name: string) => Item;
|
|
13
|
+
/**
|
|
14
|
+
* Will be called when new file is found
|
|
15
|
+
*/
|
|
16
|
+
cb?: (name: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Matches specific files format
|
|
19
|
+
*/
|
|
20
|
+
fileFormat?: RegExp;
|
|
21
|
+
/**
|
|
22
|
+
* Wether to search recursively
|
|
23
|
+
*/
|
|
24
|
+
recursive?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Using @var path find all files and generate output using @var resolveItem function for each file
|
|
28
|
+
* Can be used to generate list of components, templates, etc.
|
|
29
|
+
* @param {GetItemsSettings} settings
|
|
30
|
+
* @returns {Item[]} list of items
|
|
31
|
+
*/
|
|
32
|
+
export declare function getItems<Item>(settings: GetItemsSettings<Item>): Item[];
|