sb-mig 2.9.3 → 3.0.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.
Files changed (81) hide show
  1. package/README.md +107 -471
  2. package/dist/api/componentPresets.d.ts +1 -0
  3. package/dist/api/componentPresets.js +18 -0
  4. package/{lib → dist}/api/components.d.ts +2 -2
  5. package/dist/api/components.js +63 -0
  6. package/dist/api/config.d.ts +2 -0
  7. package/dist/api/config.js +4 -0
  8. package/{lib → dist}/api/datasources.d.ts +1 -1
  9. package/dist/api/datasources.js +181 -0
  10. package/dist/api/migrate.d.ts +17 -0
  11. package/dist/api/migrate.js +139 -0
  12. package/{lib → dist}/api/mutateComponents.d.ts +0 -0
  13. package/dist/api/mutateComponents.js +45 -0
  14. package/{lib → dist}/api/presets.d.ts +1 -1
  15. package/dist/api/presets.js +52 -0
  16. package/{lib → dist}/api/resolvePresets.d.ts +0 -0
  17. package/{lib → dist}/api/resolvePresets.js +15 -14
  18. package/{lib → dist}/api/roles.d.ts +2 -2
  19. package/dist/api/roles.js +125 -0
  20. package/dist/cli-descriptions.d.ts +4 -0
  21. package/dist/cli-descriptions.js +69 -0
  22. package/dist/commands/backup.d.ts +2 -0
  23. package/dist/commands/backup.js +201 -0
  24. package/dist/commands/debug.d.ts +1 -0
  25. package/dist/commands/debug.js +5 -0
  26. package/dist/commands/sync.d.ts +2 -0
  27. package/dist/commands/sync.js +58 -0
  28. package/dist/config/config.d.ts +14 -0
  29. package/dist/config/config.js +49 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +52 -0
  32. package/{lib/utils/discover2.d.ts → dist/utils/discover.d.ts} +1 -7
  33. package/{lib/utils/discover2.js → dist/utils/discover.js} +200 -143
  34. package/{lib → dist}/utils/files.d.ts +7 -1
  35. package/dist/utils/files.js +54 -0
  36. package/dist/utils/interfaces.d.ts +4 -0
  37. package/dist/utils/interfaces.js +1 -0
  38. package/{lib → dist}/utils/logger.d.ts +0 -3
  39. package/{lib → dist}/utils/logger.js +2 -12
  40. package/dist/utils/main.d.ts +13 -0
  41. package/dist/utils/main.js +28 -0
  42. package/{lib → dist}/utils/others.d.ts +0 -0
  43. package/dist/utils/others.js +1 -0
  44. package/package.json +63 -57
  45. package/CHANGELOG.md +0 -996
  46. package/bin/run +0 -5
  47. package/bin/run.cmd +0 -3
  48. package/lib/api/apiConfig.d.ts +0 -2
  49. package/lib/api/apiConfig.js +0 -9
  50. package/lib/api/componentPresets.d.ts +0 -1
  51. package/lib/api/componentPresets.js +0 -22
  52. package/lib/api/components.js +0 -71
  53. package/lib/api/datasources.js +0 -193
  54. package/lib/api/migrate.d.ts +0 -19
  55. package/lib/api/migrate.js +0 -220
  56. package/lib/api/mutateComponents.js +0 -50
  57. package/lib/api/presets.js +0 -59
  58. package/lib/api/roles.js +0 -133
  59. package/lib/api/spaces.d.ts +0 -2
  60. package/lib/api/spaces.js +0 -29
  61. package/lib/commands/backup.d.ts +0 -22
  62. package/lib/commands/backup.js +0 -217
  63. package/lib/commands/debug.d.ts +0 -9
  64. package/lib/commands/debug.js +0 -21
  65. package/lib/commands/sync.d.ts +0 -26
  66. package/lib/commands/sync.js +0 -93
  67. package/lib/config/StoryblokComponentsConfig.d.ts +0 -68
  68. package/lib/config/StoryblokComponentsConfig.js +0 -220
  69. package/lib/config/config.d.ts +0 -37
  70. package/lib/config/config.js +0 -36
  71. package/lib/core.d.ts +0 -16
  72. package/lib/core.js +0 -75
  73. package/lib/index.d.ts +0 -1
  74. package/lib/index.js +0 -5
  75. package/lib/types/storyblokTypes.d.ts +0 -171
  76. package/lib/types/storyblokTypes.js +0 -3
  77. package/lib/utils/discover.d.ts +0 -4
  78. package/lib/utils/discover.js +0 -96
  79. package/lib/utils/files.js +0 -54
  80. package/lib/utils/others.js +0 -5
  81. package/oclif.manifest.json +0 -1
@@ -1,6 +1,12 @@
1
- export declare const getCurrentDirectoryBase: () => string;
2
1
  export declare const isDirectoryExists: (path: string) => boolean;
3
2
  export declare const createDir: (dirPath: string) => Promise<void>;
4
3
  export declare const createJsonFile: (content: string, pathWithFilename: string) => Promise<void>;
5
4
  export declare const copyFolder: (src: string, dest: string) => Promise<unknown>;
6
5
  export declare const copyFile: (src: string, dest: string) => Promise<void>;
6
+ interface CreateAndSaveToFile {
7
+ prefix: string;
8
+ folder: string;
9
+ res: any;
10
+ }
11
+ export declare const createAndSaveToFile: ({ prefix, folder, res, }: CreateAndSaveToFile) => Promise<void>;
12
+ export {};
@@ -0,0 +1,54 @@
1
+ import * as fs from "fs";
2
+ import pkg from "ncp";
3
+ import { generateDatestamp } from "./others.js";
4
+ import storyblokConfig from "../config/config.js";
5
+ import Logger from "./logger.js";
6
+ const { ncp } = pkg;
7
+ export const isDirectoryExists = (path) => fs.existsSync(path);
8
+ export const createDir = async (dirPath) => {
9
+ await fs.promises.mkdir(`${process.cwd()}/${dirPath}`, {
10
+ recursive: true,
11
+ });
12
+ };
13
+ export const createJsonFile = async (content, pathWithFilename) => {
14
+ await fs.promises.writeFile(pathWithFilename, content, { flag: "w" });
15
+ };
16
+ export const copyFolder = async (src, dest) => {
17
+ return new Promise((resolve, reject) => {
18
+ ncp(src, dest, function (err) {
19
+ if (err) {
20
+ reject({
21
+ failed: true,
22
+ message: `${src} copied unsuccessfully.`,
23
+ });
24
+ }
25
+ resolve({
26
+ failed: false,
27
+ message: `${src} copied successfully.`,
28
+ });
29
+ });
30
+ });
31
+ };
32
+ export const copyFile = async (src, dest) => {
33
+ const directory = dest.split("/").slice(0, dest.split("/").length - 1);
34
+ const fileName = src.split("/")[src.split("/").length - 1];
35
+ if (!isDirectoryExists(directory.join("/"))) {
36
+ await createDir(directory.join("/"));
37
+ }
38
+ fs.copyFile(src, dest, (err) => {
39
+ if (err) {
40
+ console.error(`There is no file to copy, named ${fileName}`);
41
+ console.log(err);
42
+ return false;
43
+ }
44
+ console.log(`${fileName} was copied to ${dest}`);
45
+ return true;
46
+ });
47
+ };
48
+ export const createAndSaveToFile = async ({ prefix, folder, res, }) => {
49
+ const datestamp = new Date();
50
+ const filename = `${prefix}${generateDatestamp(datestamp)}`;
51
+ await createDir(`${storyblokConfig.sbmigWorkingDirectory}/${folder}/`);
52
+ await createJsonFile(JSON.stringify(res, undefined, 2), `${storyblokConfig.sbmigWorkingDirectory}/${folder}/${filename}.json`);
53
+ Logger.success(`All groups written to a file: ${filename}`);
54
+ };
@@ -0,0 +1,4 @@
1
+ import { AnyFlags, Result } from "meow";
2
+ export interface CLIOptions extends Omit<Result<AnyFlags>, "flags"> {
3
+ flags: any;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,4 @@
1
1
  export default class Logger {
2
- name: any;
3
- constructor(name: any);
4
- static bigLog(content: any): void;
5
2
  static log(content: any): void;
6
3
  static success(content: any): void;
7
4
  static warning(content: any): void;
@@ -1,14 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
- const figlet = require("figlet");
5
- class Logger {
6
- constructor(name) {
7
- this.name = name;
8
- }
9
- static bigLog(content) {
10
- console.log(chalk.yellow(figlet.textSync(content, { horizontalLayout: 'full' })));
11
- }
1
+ import chalk from "chalk";
2
+ export default class Logger {
12
3
  static log(content) {
13
4
  console.log(content);
14
5
  }
@@ -27,4 +18,3 @@ class Logger {
27
18
  }
28
19
  }
29
20
  }
30
- exports.default = Logger;
@@ -0,0 +1,13 @@
1
+ export declare const prop: (k: any) => (o: any) => any;
2
+ export declare const pipe: (...fns: any[]) => (x: any) => any;
3
+ export declare const unpackElements: (input: string[]) => string[];
4
+ export declare const unpackOne: (input: string[]) => string | undefined;
5
+ export declare const getFileContent: (data: {
6
+ file: string;
7
+ }) => any;
8
+ export declare const getFileContentWithRequire: (data: {
9
+ file: string;
10
+ }) => any;
11
+ export declare const getFilesContentWithRequire: (data: {
12
+ files: string[];
13
+ }) => any[];
@@ -0,0 +1,28 @@
1
+ import { createRequire } from "module";
2
+ export const prop = (k) => (o) => o[k];
3
+ export const pipe = (...fns) => (x) => [...fns].reduce((acc, f) => f(acc), x);
4
+ export const unpackElements = (input) => {
5
+ const [_1, _2, ...elementsForUse] = input;
6
+ return elementsForUse;
7
+ };
8
+ export const unpackOne = (input) => {
9
+ const [_1, _2, elementForUse] = input;
10
+ return elementForUse;
11
+ };
12
+ export const getFileContent = (data) => {
13
+ return import(data.file)
14
+ .then((res) => {
15
+ return res.default;
16
+ })
17
+ .catch(() => {
18
+ console.log("Cannot find requested file.");
19
+ });
20
+ };
21
+ export const getFileContentWithRequire = (data) => {
22
+ const require = createRequire(import.meta.url);
23
+ return require(data.file);
24
+ };
25
+ export const getFilesContentWithRequire = (data) => {
26
+ const require = createRequire(import.meta.url);
27
+ return data.files.map((file) => require(file));
28
+ };
File without changes
@@ -0,0 +1 @@
1
+ export const generateDatestamp = (datestamp) => `${datestamp.getFullYear()}-${datestamp.getMonth()}-${datestamp.getDay()}_${datestamp.getTime()}`;
package/package.json CHANGED
@@ -1,74 +1,80 @@
1
1
  {
2
2
  "name": "sb-mig",
3
- "version": "2.9.3",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "CLI to rule the world. (and handle stuff related to Storyblok CMS)",
5
5
  "author": "Marcin Krawczyk <marckraw@icloud.com>",
6
- "bin": {
7
- "sb-mig": "./bin/run"
8
- },
9
- "bugs": "https://github.com/sb-mig/sb-mig/issues",
10
- "dependencies": {
11
- "@oclif/command": "^1.8.0",
12
- "@oclif/plugin-plugins": "^1.7.10",
13
- "@oclif/plugin-warn-if-update-available": "^1.7.0",
14
- "axios": "^0.21.4",
15
- "camelcase": "^6.2.0",
16
- "dotenv": "^8.2.0",
17
- "glob": "^7.1.6",
18
- "ncp": "^2.0.0",
19
- "rimraf": "^3.0.2",
20
- "storyblok-js-client": "^3.3.1"
21
- },
22
- "devDependencies": {
23
- "@oclif/dev-cli": "^1",
24
- "@oclif/test": "^1",
25
- "conventional-changelog-cli": "^2.0.31",
26
- "eslint-config-oclif": "^3.1"
6
+ "license": "MIT",
7
+ "bin": "./dist/index.js",
8
+ "main": "./dist/index.js",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/sb-mig/sb-mig.git"
27
12
  },
28
- "engines": {
29
- "node": ">=8.0.0"
13
+ "publishConfig": {
14
+ "registry": "https://registry.npmjs.org/",
15
+ "access": "public"
30
16
  },
31
- "files": [
32
- "/bin",
33
- "/lib",
34
- "/npm-shrinkwrap.json",
35
- "/oclif.manifest.json"
36
- ],
37
- "homepage": "https://sb-mig.com",
17
+ "bugs": "https://github.com/sb-mig/sb-mig/issues",
18
+ "homepage": "https://github.com/sb-mig/sb-mig",
38
19
  "keywords": [
39
20
  "cli",
40
21
  "storyblok",
41
22
  "sb",
42
23
  "migrate"
43
24
  ],
44
- "license": "MIT",
45
- "main": "lib/index.js",
46
- "oclif": {
47
- "commands": "./lib/commands",
48
- "bin": "sb-mig",
49
- "scope": "sb-mig",
50
- "plugins": [
51
- "@oclif/plugin-help",
52
- "@oclif/plugin-plugins",
53
- "@oclif/plugin-warn-if-update-available"
54
- ],
55
- "warn-if-update-available": {
56
- "timeoutInDays": 3,
57
- "message": "<%= config.name %> update available from <%= chalk.greenBright(config.version) %> to <%= chalk.greenBright(latest) %>."
58
- }
25
+ "type": "module",
26
+ "exports": {
27
+ ".": "./dist/index.js",
28
+ "./dist/*": "./dist/*"
59
29
  },
60
- "repository": {
61
- "type": "git",
62
- "url": "git+https://github.com/sb-mig/sb-mig.git"
30
+ "engines": {
31
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
63
32
  },
33
+ "files": [
34
+ "/dist"
35
+ ],
64
36
  "scripts": {
65
- "postpack": "rm -f oclif.manifest.json",
66
- "posttest": "eslint . --ext .ts --config .eslintrc",
67
- "build": "rm -rf lib && tsc -b",
68
- "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
69
- "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
70
- "version": "conventional-changelog -p eslint -i CHANGELOG.md -s && oclif-dev readme && git add README.md && git add CHANGELOG.md"
37
+ "lint-staged": "lint-staged",
38
+ "build": "rm -rf dist && tsc",
39
+ "build:dev": "rm -rf dist && tsc && chmod +x ./dist/index.js",
40
+ "test": "echo \"Error: no test specified\" && exit 1",
41
+ "start": "yarn build && ./dist/index.js",
42
+ "debug": "yarn build && ./dist/index.js sync components accordion accordion-item",
43
+ "version": "conventional-changelog -p eslint -i CHANGELOG.md -s",
44
+ "semantic-release": "semantic-release",
45
+ "prepare": "husky install"
71
46
  },
72
- "types": "lib/index.d.ts",
73
- "gitHead": "d2d2c915043f6228bbda2117f7393896b867bd60"
47
+ "dependencies": {
48
+ "axios": "^0.27.2",
49
+ "chalk": "^5.0.0",
50
+ "dotenv": "^14.3.1",
51
+ "glob": "^7.2.0",
52
+ "meow": "^10.1.2",
53
+ "ncp": "^2.0.0",
54
+ "storyblok-js-client": "^4.2.0"
55
+ },
56
+ "devDependencies": {
57
+ "@commitlint/cli": "^17.0.0",
58
+ "@commitlint/config-conventional": "^17.0.0",
59
+ "@semantic-release/changelog": "^6.0.1",
60
+ "@semantic-release/git": "^10.0.1",
61
+ "@sindresorhus/tsconfig": "^2.0.0",
62
+ "@types/glob": "^7.2.0",
63
+ "@types/ncp": "^2.0.5",
64
+ "@types/node": "^17.0.35",
65
+ "commitizen": "^4.0.4",
66
+ "conventional-changelog-cli": "^2.0.31",
67
+ "eslint": "^8.16.0",
68
+ "eslint-config-prettier": "^8.5.0",
69
+ "husky": "^8.0.1",
70
+ "lint-staged": "^12.4.1",
71
+ "prettier": "^2.6.2",
72
+ "semantic-release": "^19.0.2",
73
+ "typescript": "^4.6.4"
74
+ },
75
+ "config": {
76
+ "commitizen": {
77
+ "path": "./node_modules/cz-conventional-changelog"
78
+ }
79
+ }
74
80
  }