sb-mig 5.5.4-beta.1 → 5.6.0-beta.2
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/README.md +20 -19
- package/dist/api/assets/assets.js +1 -14
- package/dist/api/components/components.js +2 -1
- package/dist/api/components/components.sync.d.ts +8 -0
- package/dist/api/components/components.sync.js +193 -0
- package/dist/api/data-migration/component-data-migration.d.ts +6 -2
- package/dist/api/data-migration/component-data-migration.js +35 -11
- package/dist/api/datasources/datasource-entries.js +4 -5
- package/dist/api/datasources/datasources.d.ts +5 -2
- package/dist/api/datasources/datasources.js +42 -35
- package/dist/api/datasources/datasources.sync.d.ts +2 -0
- package/dist/api/datasources/datasources.sync.js +11 -0
- package/dist/api/datasources/datasources.types.d.ts +1 -1
- package/dist/api/datasources/index.d.ts +2 -1
- package/dist/api/datasources/index.js +2 -1
- package/dist/api/managementApi.d.ts +2 -2
- package/dist/api/migrate.d.ts +1 -1
- package/dist/api/migrate.js +3 -48
- package/dist/api/plugins/index.d.ts +2 -1
- package/dist/api/plugins/index.js +2 -1
- package/dist/api/plugins/plugins.d.ts +7 -2
- package/dist/api/plugins/plugins.js +28 -15
- package/dist/api/plugins/plugins.sync.d.ts +2 -0
- package/dist/api/plugins/plugins.sync.js +11 -0
- package/dist/api/roles/index.d.ts +2 -1
- package/dist/api/roles/index.js +2 -1
- package/dist/api/roles/roles.d.ts +5 -2
- package/dist/api/roles/roles.js +34 -11
- package/dist/api/roles/roles.sync.d.ts +2 -0
- package/dist/api/roles/roles.sync.js +6 -0
- package/dist/api/roles/roles.types.d.ts +1 -1
- package/dist/api/stories/stories.js +5 -13
- package/dist/api/sync/sync.types.d.ts +30 -0
- package/dist/api/sync/sync.types.js +1 -0
- package/dist/api/testApi.d.ts +2 -2
- package/dist/api/utils/helper-functions.d.ts +5 -1
- package/dist/api/utils/helper-functions.js +6 -1
- package/dist/api/utils/request.d.ts +1 -1
- package/dist/api/utils/request.js +11 -2
- package/dist/api/utils/resolverTransformations.js +2 -57
- package/dist/api-v2/assets/index.d.ts +13 -0
- package/dist/api-v2/assets/index.js +25 -0
- package/dist/api-v2/auth/index.d.ts +3 -0
- package/dist/api-v2/auth/index.js +8 -0
- package/dist/api-v2/client.d.ts +13 -0
- package/dist/api-v2/client.js +17 -0
- package/dist/api-v2/components/index.d.ts +10 -0
- package/dist/api-v2/components/index.js +29 -0
- package/dist/api-v2/datasources/index.d.ts +8 -0
- package/dist/api-v2/datasources/index.js +58 -0
- package/dist/api-v2/discover/discover.d.ts +36 -0
- package/dist/api-v2/discover/discover.js +281 -0
- package/dist/api-v2/discover/index.d.ts +2 -0
- package/dist/api-v2/discover/index.js +1 -0
- package/dist/api-v2/index.d.ts +19 -0
- package/dist/api-v2/index.js +21 -0
- package/dist/api-v2/plugins/index.d.ts +9 -0
- package/dist/api-v2/plugins/index.js +42 -0
- package/dist/api-v2/precompile/index.d.ts +2 -0
- package/dist/api-v2/precompile/index.js +1 -0
- package/dist/api-v2/precompile/precompile.d.ts +65 -0
- package/dist/api-v2/precompile/precompile.js +127 -0
- package/dist/api-v2/presets/index.d.ts +13 -0
- package/dist/api-v2/presets/index.js +25 -0
- package/dist/api-v2/requestConfig.d.ts +5 -0
- package/dist/api-v2/requestConfig.js +34 -0
- package/dist/api-v2/roles/index.d.ts +5 -0
- package/dist/api-v2/roles/index.js +35 -0
- package/dist/api-v2/spaces/index.d.ts +7 -0
- package/dist/api-v2/spaces/index.js +11 -0
- package/dist/api-v2/stories/index.d.ts +34 -0
- package/dist/api-v2/stories/index.js +172 -0
- package/dist/api-v2/stories/types.d.ts +28 -0
- package/dist/api-v2/stories/types.js +1 -0
- package/dist/api-v2/sync/index.d.ts +24 -0
- package/dist/api-v2/sync/index.js +109 -0
- package/dist/api-v2/sync/types.d.ts +1 -0
- package/dist/api-v2/sync/types.js +1 -0
- package/dist/api-v2/test.d.ts +15 -0
- package/dist/api-v2/test.js +21 -0
- package/dist/cli/cli-descriptions.d.ts +1 -1
- package/dist/cli/cli-descriptions.js +4 -0
- package/dist/cli/commands/backup.js +7 -3
- package/dist/cli/commands/copy.js +2 -2
- package/dist/cli/commands/migrate.js +13 -2
- package/dist/cli/commands/migrations.js +2 -2
- package/dist/cli/commands/remove.js +1 -1
- package/dist/cli/commands/revert.js +2 -2
- package/dist/cli/commands/sync.js +1 -2
- package/dist/cli/index.js +8 -1
- package/dist/cli/utils/cli-utils.d.ts +69 -0
- package/dist/cli/utils/cli-utils.js +100 -0
- package/dist/cli/utils/discover.d.ts +3 -22
- package/dist/cli/utils/discover.js +4 -51
- package/dist/config/config.d.ts +2 -39
- package/dist/config/config.types.d.ts +40 -0
- package/dist/config/config.types.js +1 -0
- package/dist/config/defaultConfig.d.ts +1 -1
- package/dist/config/defaultConfig.js +2 -2
- package/dist/utils/array-utils.d.ts +20 -0
- package/dist/utils/array-utils.js +20 -0
- package/dist/utils/async-utils.d.ts +13 -0
- package/dist/utils/async-utils.js +13 -0
- package/dist/utils/date-utils.d.ts +14 -0
- package/dist/utils/date-utils.js +21 -0
- package/dist/utils/files.d.ts +35 -0
- package/dist/utils/files.js +57 -2
- package/dist/utils/main.d.ts +8 -18
- package/dist/utils/main.js +12 -104
- package/dist/utils/migrations.d.ts +9 -3
- package/dist/utils/object-utils.d.ts +46 -0
- package/dist/utils/object-utils.js +71 -0
- package/dist/utils/others.d.ts +6 -9
- package/dist/utils/others.js +8 -15
- package/dist/utils/path-utils.d.ts +89 -0
- package/dist/utils/path-utils.js +106 -0
- package/dist/utils/pkg.d.ts +16 -2
- package/dist/utils/pkg.js +16 -3
- package/dist/utils/string-utils.d.ts +33 -0
- package/dist/utils/string-utils.js +45 -0
- package/dist/utils/transform-utils.d.ts +62 -0
- package/dist/utils/transform-utils.js +113 -0
- package/dist-cjs/api/auth/auth.js +28 -0
- package/dist-cjs/api/auth/auth.types.js +2 -0
- package/dist-cjs/api/components/components.js +202 -0
- package/dist-cjs/api/components/components.sync.js +199 -0
- package/dist-cjs/api/components/components.types.js +2 -0
- package/dist-cjs/api/datasources/datasource-entries.js +166 -0
- package/dist-cjs/api/datasources/datasources.js +166 -0
- package/dist-cjs/api/datasources/datasources.types.js +2 -0
- package/dist-cjs/api/plugins/plugins.js +132 -0
- package/dist-cjs/api/plugins/plugins.types.js +2 -0
- package/dist-cjs/api/presets/componentPresets.js +25 -0
- package/dist-cjs/api/presets/presets.js +92 -0
- package/dist-cjs/api/presets/presets.types.js +2 -0
- package/dist-cjs/api/presets/resolvePresets.js +49 -0
- package/dist-cjs/api/roles/roles.js +131 -0
- package/dist-cjs/api/roles/roles.types.js +2 -0
- package/dist-cjs/api/spaces/spaces.js +34 -0
- package/dist-cjs/api/spaces/spaces.types.js +2 -0
- package/dist-cjs/api/stories/stories.js +214 -0
- package/dist-cjs/api/stories/stories.types.js +2 -0
- package/dist-cjs/api/sync/sync.types.js +2 -0
- package/dist-cjs/api/utils/request.js +48 -0
- package/dist-cjs/api/utils/resolvers.types.js +2 -0
- package/dist-cjs/api-v2/assets/index.js +30 -0
- package/dist-cjs/api-v2/auth/index.js +12 -0
- package/dist-cjs/api-v2/client.js +23 -0
- package/dist-cjs/api-v2/components/index.js +40 -0
- package/dist-cjs/api-v2/datasources/index.js +64 -0
- package/dist-cjs/api-v2/discover/discover.js +321 -0
- package/dist-cjs/api-v2/discover/index.js +9 -0
- package/dist-cjs/api-v2/index.js +60 -0
- package/dist-cjs/api-v2/plugins/index.js +49 -0
- package/dist-cjs/api-v2/precompile/index.js +7 -0
- package/dist-cjs/api-v2/precompile/precompile.js +136 -0
- package/dist-cjs/api-v2/presets/index.js +33 -0
- package/dist-cjs/api-v2/requestConfig.js +37 -0
- package/dist-cjs/api-v2/roles/index.js +41 -0
- package/dist-cjs/api-v2/spaces/index.js +16 -0
- package/dist-cjs/api-v2/stories/index.js +180 -0
- package/dist-cjs/api-v2/stories/types.js +2 -0
- package/dist-cjs/api-v2/sync/index.js +115 -0
- package/dist-cjs/api-v2/sync/types.js +2 -0
- package/dist-cjs/api-v2/test.js +25 -0
- package/dist-cjs/config/config.types.js +2 -0
- package/dist-cjs/config/constants.js +29 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/utils/array-utils.js +24 -0
- package/dist-cjs/utils/logger.js +32 -0
- package/dist-cjs/utils/object-utils.js +77 -0
- package/dist-cjs/utils/path-utils.js +115 -0
- package/package.json +37 -20
- package/dist/utils/pkg-require.d.ts +0 -2
- package/dist/utils/pkg-require.js +0 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get unique values from an array
|
|
6
|
+
* Uses Set for O(n) deduplication
|
|
7
|
+
*
|
|
8
|
+
* @param array - The array to deduplicate
|
|
9
|
+
* @returns A new array with only unique values
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* uniqueValuesFrom([1, 2, 2, 3, 3, 3]) // => [1, 2, 3]
|
|
13
|
+
* uniqueValuesFrom(['a', 'b', 'a']) // => ['a', 'b']
|
|
14
|
+
*/
|
|
15
|
+
export declare const uniqueValuesFrom: <T>(array: T[]) => T[];
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use uniqueValuesFrom instead
|
|
18
|
+
* Alias for backwards compatibility
|
|
19
|
+
*/
|
|
20
|
+
export declare const _uniqueValuesFrom: <T>(array: T[]) => T[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get unique values from an array
|
|
6
|
+
* Uses Set for O(n) deduplication
|
|
7
|
+
*
|
|
8
|
+
* @param array - The array to deduplicate
|
|
9
|
+
* @returns A new array with only unique values
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* uniqueValuesFrom([1, 2, 2, 3, 3, 3]) // => [1, 2, 3]
|
|
13
|
+
* uniqueValuesFrom(['a', 'b', 'a']) // => ['a', 'b']
|
|
14
|
+
*/
|
|
15
|
+
export const uniqueValuesFrom = (array) => [...new Set(array)];
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use uniqueValuesFrom instead
|
|
18
|
+
* Alias for backwards compatibility
|
|
19
|
+
*/
|
|
20
|
+
export const _uniqueValuesFrom = uniqueValuesFrom;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Delay execution for a specified time
|
|
6
|
+
*
|
|
7
|
+
* @param time - Time to delay in milliseconds
|
|
8
|
+
* @returns Promise that resolves after the delay
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* await delay(1000); // Wait 1 second
|
|
12
|
+
*/
|
|
13
|
+
export declare const delay: (time: number) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Delay execution for a specified time
|
|
6
|
+
*
|
|
7
|
+
* @param time - Time to delay in milliseconds
|
|
8
|
+
* @returns Promise that resolves after the delay
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* await delay(1000); // Wait 1 second
|
|
12
|
+
*/
|
|
13
|
+
export const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate a datestamp string from a Date object
|
|
6
|
+
* Format: YYYY-M-D_H-M (no zero-padding)
|
|
7
|
+
*
|
|
8
|
+
* @param datestamp - The Date object to format
|
|
9
|
+
* @returns Formatted date string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* generateDatestamp(new Date('2024-03-15T10:30:00')) // => '2024-3-15_10-30'
|
|
13
|
+
*/
|
|
14
|
+
export declare const generateDatestamp: (datestamp: Date) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate a datestamp string from a Date object
|
|
6
|
+
* Format: YYYY-M-D_H-M (no zero-padding)
|
|
7
|
+
*
|
|
8
|
+
* @param datestamp - The Date object to format
|
|
9
|
+
* @returns Formatted date string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* generateDatestamp(new Date('2024-03-15T10:30:00')) // => '2024-3-15_10-30'
|
|
13
|
+
*/
|
|
14
|
+
export const generateDatestamp = (datestamp) => {
|
|
15
|
+
const year = datestamp.getFullYear();
|
|
16
|
+
const month = datestamp.getMonth() + 1;
|
|
17
|
+
const day = datestamp.getDate();
|
|
18
|
+
const hours = datestamp.getHours();
|
|
19
|
+
const minutes = datestamp.getMinutes();
|
|
20
|
+
return `${year}-${month}-${day}_${hours}-${minutes}`;
|
|
21
|
+
};
|
package/dist/utils/files.d.ts
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
import type { RequestBaseConfig } from "../api/utils/request.js";
|
|
2
|
+
/**
|
|
3
|
+
* Asynchronously load a file using dynamic import
|
|
4
|
+
* Returns the default export of the module
|
|
5
|
+
*
|
|
6
|
+
* @param data - Object containing the file path
|
|
7
|
+
* @returns The default export of the imported module
|
|
8
|
+
*/
|
|
9
|
+
export declare const getFileContent: (data: {
|
|
10
|
+
file: string;
|
|
11
|
+
}) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Synchronously load a file using require
|
|
14
|
+
* Handles both CommonJS and ES modules with default exports
|
|
15
|
+
*
|
|
16
|
+
* @param data - Object containing the file path
|
|
17
|
+
* @returns The file content (default export if available)
|
|
18
|
+
*/
|
|
19
|
+
export declare const getFileContentWithRequire: (data: {
|
|
20
|
+
file: string;
|
|
21
|
+
}) => any;
|
|
22
|
+
/**
|
|
23
|
+
* Load multiple files using require
|
|
24
|
+
*
|
|
25
|
+
* @param data - Object containing array of file paths
|
|
26
|
+
* @returns Array of file contents
|
|
27
|
+
*/
|
|
28
|
+
export declare const getFilesContentWithRequire: (data: {
|
|
29
|
+
files: string[];
|
|
30
|
+
}) => any[];
|
|
31
|
+
/**
|
|
32
|
+
* Read and parse the package.json from current working directory
|
|
33
|
+
*
|
|
34
|
+
* @returns Parsed package.json object
|
|
35
|
+
*/
|
|
36
|
+
export declare const getPackageJson: () => any;
|
|
2
37
|
export declare const isDirectoryExists: (path: string) => boolean;
|
|
3
38
|
export declare const createDir: (dirPath: string) => Promise<void>;
|
|
4
39
|
export declare const createJsonFile: (content: string, pathWithFilename: string) => Promise<void>;
|
package/dist/utils/files.js
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import { writeFile } from "fs";
|
|
3
|
+
import { createRequire } from "module";
|
|
3
4
|
import path from "path";
|
|
4
5
|
import pkg from "ncp";
|
|
6
|
+
import { generateDatestamp } from "./date-utils.js";
|
|
5
7
|
import Logger from "./logger.js";
|
|
6
|
-
import { getFileContentWithRequire } from "./main.js";
|
|
7
|
-
import { generateDatestamp } from "./others.js";
|
|
8
8
|
const { ncp } = pkg;
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// File Content Loading
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Asynchronously load a file using dynamic import
|
|
14
|
+
* Returns the default export of the module
|
|
15
|
+
*
|
|
16
|
+
* @param data - Object containing the file path
|
|
17
|
+
* @returns The default export of the imported module
|
|
18
|
+
*/
|
|
19
|
+
export const getFileContent = (data) => {
|
|
20
|
+
return import(data.file)
|
|
21
|
+
.then((res) => {
|
|
22
|
+
return res.default;
|
|
23
|
+
})
|
|
24
|
+
.catch((err) => {
|
|
25
|
+
console.log(err);
|
|
26
|
+
console.log("Cannot find requested file.");
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Synchronously load a file using require
|
|
31
|
+
* Handles both CommonJS and ES modules with default exports
|
|
32
|
+
*
|
|
33
|
+
* @param data - Object containing the file path
|
|
34
|
+
* @returns The file content (default export if available)
|
|
35
|
+
*/
|
|
36
|
+
export const getFileContentWithRequire = (data) => {
|
|
37
|
+
const require = createRequire(import.meta.url);
|
|
38
|
+
const fileContent = require(data.file);
|
|
39
|
+
if (fileContent.default) {
|
|
40
|
+
return fileContent.default;
|
|
41
|
+
}
|
|
42
|
+
return fileContent;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Load multiple files using require
|
|
46
|
+
*
|
|
47
|
+
* @param data - Object containing array of file paths
|
|
48
|
+
* @returns Array of file contents
|
|
49
|
+
*/
|
|
50
|
+
export const getFilesContentWithRequire = (data) => {
|
|
51
|
+
return data.files.map((file) => getFileContentWithRequire({ file }));
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Read and parse the package.json from current working directory
|
|
55
|
+
*
|
|
56
|
+
* @returns Parsed package.json object
|
|
57
|
+
*/
|
|
58
|
+
export const getPackageJson = () => {
|
|
59
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
60
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
61
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
62
|
+
return packageJson;
|
|
63
|
+
};
|
|
9
64
|
export const isDirectoryExists = (path) => fs.existsSync(path);
|
|
10
65
|
export const createDir = async (dirPath) => {
|
|
11
66
|
await fs.promises.mkdir(`${process.cwd()}/${dirPath}`, {
|
package/dist/utils/main.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export
|
|
9
|
-
file: string;
|
|
10
|
-
}) => any;
|
|
11
|
-
export declare const getFilesContentWithRequire: (data: {
|
|
12
|
-
files: string[];
|
|
13
|
-
}) => any[];
|
|
14
|
-
export declare const isObjectEmpty: (obj: any) => boolean;
|
|
15
|
-
export declare const delay: (time: number) => Promise<unknown>;
|
|
16
|
-
export declare const isItFactory: <T>(flags: any, rules: any, whitelist: string[]) => (type: T) => boolean;
|
|
17
|
-
export declare const getPackageJson: () => any;
|
|
18
|
-
export declare const extractFields: (data: any, filter: any) => any;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for backwards compatibility
|
|
3
|
+
* Functions have been moved to their proper modules
|
|
4
|
+
*/
|
|
5
|
+
export { prop, pipe, unpackElements, unpackOne, isItFactory, } from "../cli/utils/cli-utils.js";
|
|
6
|
+
export { isObjectEmpty, extractFields } from "./object-utils.js";
|
|
7
|
+
export { getFileContent, getFileContentWithRequire, getFilesContentWithRequire, getPackageJson, } from "./files.js";
|
|
8
|
+
export { delay } from "./async-utils.js";
|
package/dist/utils/main.js
CHANGED
|
@@ -1,104 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export const getFileContent = (data) => {
|
|
15
|
-
return import(data.file)
|
|
16
|
-
.then((res) => {
|
|
17
|
-
return res.default;
|
|
18
|
-
})
|
|
19
|
-
.catch((err) => {
|
|
20
|
-
console.log(err);
|
|
21
|
-
console.log("Cannot find requested file.");
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export const getFileContentWithRequire = (data) => {
|
|
25
|
-
const require = createRequire(import.meta.url);
|
|
26
|
-
const fileContent = require(data.file);
|
|
27
|
-
if (fileContent.default) {
|
|
28
|
-
return fileContent.default;
|
|
29
|
-
}
|
|
30
|
-
return fileContent;
|
|
31
|
-
};
|
|
32
|
-
export const getFilesContentWithRequire = (data) => {
|
|
33
|
-
return data.files.map((file) => getFileContentWithRequire({ file }));
|
|
34
|
-
};
|
|
35
|
-
export const isObjectEmpty = (obj) => {
|
|
36
|
-
if (obj) {
|
|
37
|
-
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
export const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
|
44
|
-
export const isItFactory = (flags, rules, whitelist) => {
|
|
45
|
-
return (type) => {
|
|
46
|
-
const rulesCopy = [...rules[type]];
|
|
47
|
-
const flagsKeys = Object.keys(flags);
|
|
48
|
-
const temp = flagsKeys.map((flag) => {
|
|
49
|
-
if (whitelist.includes(flag)) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
if (rulesCopy.includes(flag)) {
|
|
53
|
-
rulesCopy.splice(rulesCopy.indexOf(flag), 1);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
if (rulesCopy.length > 0) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return temp.every((el) => el === true);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export const getPackageJson = () => {
|
|
69
|
-
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
70
|
-
// Read the file content as a string
|
|
71
|
-
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
72
|
-
// Parse the file content as a JSON object
|
|
73
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
74
|
-
return packageJson;
|
|
75
|
-
};
|
|
76
|
-
export const extractFields = (data, filter) => {
|
|
77
|
-
const result = {};
|
|
78
|
-
for (const key in filter) {
|
|
79
|
-
if (filter[key] === true) {
|
|
80
|
-
result[key] = data[key];
|
|
81
|
-
}
|
|
82
|
-
else if (typeof filter[key] === "object") {
|
|
83
|
-
result[key] = extractFields(data[key], filter[key]);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
// export const generateMetadata = (args: any) => {
|
|
89
|
-
// const packageJson = getPackageJson();
|
|
90
|
-
//
|
|
91
|
-
// const contentHubName = packageJson.name;
|
|
92
|
-
// const contentHubLatestVersion = packageJson.version;
|
|
93
|
-
//
|
|
94
|
-
// const backpackVersionInContentHub =
|
|
95
|
-
// packageJson.dependencies['@ef-global/backpack'];
|
|
96
|
-
//
|
|
97
|
-
// return {
|
|
98
|
-
// metadata: {
|
|
99
|
-
// contentHubName,
|
|
100
|
-
// contentHubLatestVersion,
|
|
101
|
-
// backpackVersionInContentHub,
|
|
102
|
-
// },
|
|
103
|
-
// };
|
|
104
|
-
// };
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for backwards compatibility
|
|
3
|
+
* Functions have been moved to their proper modules
|
|
4
|
+
*/
|
|
5
|
+
// CLI utils - now in src/cli/utils/cli-utils.ts
|
|
6
|
+
export { prop, pipe, unpackElements, unpackOne, isItFactory, } from "../cli/utils/cli-utils.js";
|
|
7
|
+
// Object utils - now in src/utils/object-utils.ts
|
|
8
|
+
export { isObjectEmpty, extractFields } from "./object-utils.js";
|
|
9
|
+
// File loading utils - now in src/utils/files.ts
|
|
10
|
+
export { getFileContent, getFileContentWithRequire, getFilesContentWithRequire, getPackageJson, } from "./files.js";
|
|
11
|
+
// Async utils - now in src/utils/async-utils.ts
|
|
12
|
+
export { delay } from "./async-utils.js";
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Known migration names (can be extended as new migrations are added)
|
|
3
|
+
*/
|
|
4
|
+
export type MigrationNames = "transitionsOnEnter" | "otherMigration" | "cardsMigration" | "hideToVisibility";
|
|
5
|
+
/**
|
|
6
|
+
* Version mapping - maps semver versions to arrays of migration names
|
|
7
|
+
* Uses string[] to allow flexibility for new migrations
|
|
8
|
+
*/
|
|
9
|
+
export type VersionMapping = Record<string, string[]>;
|
|
3
10
|
export declare const preselectMigrations: (currentVersion: string, installedVersion: string, versionMapping: VersionMapping, alreadyApplied?: {
|
|
4
11
|
story: string[];
|
|
5
12
|
preset: string[];
|
|
@@ -8,4 +15,3 @@ export declare const preselectMigrations: (currentVersion: string, installedVers
|
|
|
8
15
|
preset: never[];
|
|
9
16
|
};
|
|
10
17
|
export declare const modifyOrCreateAppliedMigrationsFile: (migrationApplied: string, itemType: "story" | "preset") => Promise<void>;
|
|
11
|
-
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General object utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Filter out null and undefined values from an object
|
|
6
|
+
* Keeps all properties that have defined values (including falsy values like 0, '', false)
|
|
7
|
+
*
|
|
8
|
+
* @param params - The object to filter
|
|
9
|
+
* @returns A new object with only non-nullish values
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* notNullish({ a: 1, b: null, c: undefined, d: 0 }) // => { a: 1, d: 0 }
|
|
13
|
+
*/
|
|
14
|
+
export declare const notNullish: <T extends Record<string, any>>(params: T) => T;
|
|
15
|
+
/**
|
|
16
|
+
* Check if an object is empty (has no own properties)
|
|
17
|
+
* Returns true for null, undefined, and empty objects {}
|
|
18
|
+
* Returns false for arrays (even empty ones) and objects with properties
|
|
19
|
+
*
|
|
20
|
+
* @param obj - The object to check
|
|
21
|
+
* @returns true if the object is empty, null, or undefined
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* isObjectEmpty({}) // => true
|
|
25
|
+
* isObjectEmpty(null) // => true
|
|
26
|
+
* isObjectEmpty({ name: 'test' }) // => false
|
|
27
|
+
* isObjectEmpty([]) // => false (arrays are not plain objects)
|
|
28
|
+
*/
|
|
29
|
+
export declare const isObjectEmpty: (obj: any) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Extract specific fields from an object based on a filter object
|
|
32
|
+
* Supports nested object extraction
|
|
33
|
+
*
|
|
34
|
+
* @param data - The source object to extract fields from
|
|
35
|
+
* @param filter - An object where true means include the field, nested objects for nested extraction
|
|
36
|
+
* @returns A new object containing only the specified fields
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const data = { name: 'hero', id: 123, schema: { title: 'text' } };
|
|
40
|
+
* extractFields(data, { name: true, id: true }) // => { name: 'hero', id: 123 }
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Nested extraction
|
|
44
|
+
* extractFields(data, { schema: { title: true } }) // => { schema: { title: 'text' } }
|
|
45
|
+
*/
|
|
46
|
+
export declare const extractFields: (data: any, filter: any) => any;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General object utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Filter out null and undefined values from an object
|
|
6
|
+
* Keeps all properties that have defined values (including falsy values like 0, '', false)
|
|
7
|
+
*
|
|
8
|
+
* @param params - The object to filter
|
|
9
|
+
* @returns A new object with only non-nullish values
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* notNullish({ a: 1, b: null, c: undefined, d: 0 }) // => { a: 1, d: 0 }
|
|
13
|
+
*/
|
|
14
|
+
export const notNullish = (params) => {
|
|
15
|
+
return Object.keys(params).reduce((acc, key) => {
|
|
16
|
+
if (params[key] !== null && params[key] !== undefined) {
|
|
17
|
+
acc[key] = params[key];
|
|
18
|
+
}
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Check if an object is empty (has no own properties)
|
|
24
|
+
* Returns true for null, undefined, and empty objects {}
|
|
25
|
+
* Returns false for arrays (even empty ones) and objects with properties
|
|
26
|
+
*
|
|
27
|
+
* @param obj - The object to check
|
|
28
|
+
* @returns true if the object is empty, null, or undefined
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* isObjectEmpty({}) // => true
|
|
32
|
+
* isObjectEmpty(null) // => true
|
|
33
|
+
* isObjectEmpty({ name: 'test' }) // => false
|
|
34
|
+
* isObjectEmpty([]) // => false (arrays are not plain objects)
|
|
35
|
+
*/
|
|
36
|
+
export const isObjectEmpty = (obj) => {
|
|
37
|
+
if (obj) {
|
|
38
|
+
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Extract specific fields from an object based on a filter object
|
|
46
|
+
* Supports nested object extraction
|
|
47
|
+
*
|
|
48
|
+
* @param data - The source object to extract fields from
|
|
49
|
+
* @param filter - An object where true means include the field, nested objects for nested extraction
|
|
50
|
+
* @returns A new object containing only the specified fields
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const data = { name: 'hero', id: 123, schema: { title: 'text' } };
|
|
54
|
+
* extractFields(data, { name: true, id: true }) // => { name: 'hero', id: 123 }
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Nested extraction
|
|
58
|
+
* extractFields(data, { schema: { title: true } }) // => { schema: { title: 'text' } }
|
|
59
|
+
*/
|
|
60
|
+
export const extractFields = (data, filter) => {
|
|
61
|
+
const result = {};
|
|
62
|
+
for (const key in filter) {
|
|
63
|
+
if (filter[key] === true) {
|
|
64
|
+
result[key] = data[key];
|
|
65
|
+
}
|
|
66
|
+
else if (typeof filter[key] === "object") {
|
|
67
|
+
result[key] = extractFields(data[key], filter[key]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
};
|
package/dist/utils/others.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export declare const getWhat: (flags: any) => string;
|
|
8
|
-
export declare const getWhere: (flags: any) => string;
|
|
9
|
-
export declare const getRecursive: (flags: any) => boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for backwards compatibility
|
|
3
|
+
* Functions have been moved to their proper modules
|
|
4
|
+
*/
|
|
5
|
+
export { generateDatestamp } from "./date-utils.js";
|
|
6
|
+
export { getFrom, getTo, getSourceSpace, getTargetSpace, getWhat, getWhere, getRecursive, } from "../cli/utils/cli-utils.js";
|
package/dist/utils/others.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export const getFrom = (flags, config) => (flags["from"] ? flags["from"] : config.spaceId).toString();
|
|
10
|
-
export const getTo = (flags, config) => (flags["to"] ? flags["to"] : config.spaceId).toString();
|
|
11
|
-
export const getSourceSpace = (flags, config) => (flags["sourceSpace"] ? flags["sourceSpace"] : config.spaceId).toString();
|
|
12
|
-
export const getTargetSpace = (flags, config) => (flags["targetSpace"] ? flags["targetSpace"] : config.spaceId).toString();
|
|
13
|
-
export const getWhat = (flags) => (flags["what"] ? flags["what"] : "all").toString();
|
|
14
|
-
export const getWhere = (flags) => (flags["where"] ? flags["where"] : "all").toString();
|
|
15
|
-
export const getRecursive = (flags) => flags["recursive"] ? flags["recursive"] : false;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for backwards compatibility
|
|
3
|
+
* Functions have been moved to their proper modules
|
|
4
|
+
*/
|
|
5
|
+
// Date utilities - now in date-utils.ts
|
|
6
|
+
export { generateDatestamp } from "./date-utils.js";
|
|
7
|
+
// CLI flag extractors - now in cli/utils/cli-utils.ts
|
|
8
|
+
export { getFrom, getTo, getSourceSpace, getTargetSpace, getWhat, getWhere, getRecursive, } from "../cli/utils/cli-utils.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path and glob pattern utilities for file discovery
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Represents a file element with its name and path
|
|
6
|
+
*/
|
|
7
|
+
export interface OneFileElement {
|
|
8
|
+
name: string;
|
|
9
|
+
p: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Result of comparing local and external file arrays
|
|
13
|
+
*/
|
|
14
|
+
export interface CompareResult {
|
|
15
|
+
local: OneFileElement[];
|
|
16
|
+
external: OneFileElement[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Request for comparing local and external file paths
|
|
20
|
+
*/
|
|
21
|
+
interface CompareRequest {
|
|
22
|
+
local: string[];
|
|
23
|
+
external: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Normalizes an array of directory segments for glob pattern usage.
|
|
27
|
+
* Handles the glob.sync quirk where single segments don't need braces,
|
|
28
|
+
* but multiple segments need {segment1,segment2} format.
|
|
29
|
+
*
|
|
30
|
+
* @param segments - Array of directory path segments
|
|
31
|
+
* @returns Normalized string for glob pattern
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* normalizeDiscover({ segments: [] }) // => ""
|
|
35
|
+
* normalizeDiscover({ segments: ["src"] }) // => "src"
|
|
36
|
+
* normalizeDiscover({ segments: ["src", "lib"] }) // => "{src,lib}"
|
|
37
|
+
*/
|
|
38
|
+
export declare const normalizeDiscover: ({ segments, }: {
|
|
39
|
+
segments: string[];
|
|
40
|
+
}) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Builds a glob file pattern for discovering files with a specific extension.
|
|
43
|
+
* Automatically handles single vs multiple directory paths.
|
|
44
|
+
*
|
|
45
|
+
* @param mainDirectory - The root directory to search from
|
|
46
|
+
* @param componentDirectories - Array of subdirectories to search in
|
|
47
|
+
* @param ext - File extension to match (without leading dot)
|
|
48
|
+
* @returns A glob pattern string
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* filesPattern({
|
|
52
|
+
* mainDirectory: "/project",
|
|
53
|
+
* componentDirectories: ["src"],
|
|
54
|
+
* ext: "sb.js"
|
|
55
|
+
* })
|
|
56
|
+
* // => "/project/src/**\/[^_]*.sb.js"
|
|
57
|
+
*
|
|
58
|
+
* filesPattern({
|
|
59
|
+
* mainDirectory: "/project",
|
|
60
|
+
* componentDirectories: ["src", "lib"],
|
|
61
|
+
* ext: "sb.js"
|
|
62
|
+
* })
|
|
63
|
+
* // => "/project/{src,lib}/**\/[^_]*.sb.js"
|
|
64
|
+
*/
|
|
65
|
+
export declare const filesPattern: ({ mainDirectory, componentDirectories, ext, }: {
|
|
66
|
+
mainDirectory: string;
|
|
67
|
+
componentDirectories: string[];
|
|
68
|
+
ext: string;
|
|
69
|
+
}) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Compares local and external file path arrays.
|
|
72
|
+
* Splits paths to extract file names, filters out duplicates from external
|
|
73
|
+
* (preferring local files), and filters out nested node_modules.
|
|
74
|
+
*
|
|
75
|
+
* @param request - Object containing local and external path arrays
|
|
76
|
+
* @returns CompareResult with processed local and external file elements
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* compare({
|
|
80
|
+
* local: ["/project/src/hero.sb.js"],
|
|
81
|
+
* external: ["/project/node_modules/pkg/hero.sb.js", "/project/node_modules/pkg/card.sb.js"]
|
|
82
|
+
* })
|
|
83
|
+
* // => {
|
|
84
|
+
* // local: [{ name: "hero.sb.js", p: "/project/src/hero.sb.js" }],
|
|
85
|
+
* // external: [{ name: "card.sb.js", p: "/project/node_modules/pkg/card.sb.js" }]
|
|
86
|
+
* // }
|
|
87
|
+
*/
|
|
88
|
+
export declare const compare: (request: CompareRequest) => CompareResult;
|
|
89
|
+
export {};
|