@superblocksteam/cli 1.10.0 → 1.12.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 (55) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +6 -6
  3. package/assets/custom-components/setup/tsconfig.json +0 -1
  4. package/bin/dev +5 -7
  5. package/bin/run +1 -3
  6. package/dist/appendHotReloadEventPlugin.mjs +43 -0
  7. package/dist/commands/commits.d.mts +18 -0
  8. package/dist/commands/{commits.js → commits.mjs} +59 -67
  9. package/dist/commands/components/{create.d.ts → create.d.mts} +2 -2
  10. package/dist/commands/components/{create.js → create.mjs} +84 -93
  11. package/dist/commands/components/{register.d.ts → register.d.mts} +1 -1
  12. package/dist/commands/components/register.mjs +12 -0
  13. package/dist/commands/components/{upload.d.ts → upload.d.mts} +2 -2
  14. package/dist/commands/components/{upload.js → upload.mjs} +39 -43
  15. package/dist/commands/components/{watch.d.ts → watch.d.mts} +1 -1
  16. package/dist/commands/components/{watch.js → watch.mjs} +29 -36
  17. package/dist/commands/config/{set.d.ts → set.d.mts} +2 -2
  18. package/dist/commands/config/{set.js → set.mjs} +28 -32
  19. package/dist/commands/{init.d.ts → init.d.mts} +4 -4
  20. package/dist/commands/{init.js → init.mjs} +58 -64
  21. package/dist/commands/{login.d.ts → login.d.mts} +1 -1
  22. package/dist/commands/login.mjs +55 -0
  23. package/dist/commands/{migrate.d.ts → migrate.d.mts} +1 -1
  24. package/dist/commands/{migrate.js → migrate.mjs} +34 -42
  25. package/dist/commands/pull.d.mts +17 -0
  26. package/dist/commands/{pull.js → pull.mjs} +72 -80
  27. package/dist/commands/push.d.mts +15 -0
  28. package/dist/commands/{push.js → push.mjs} +81 -90
  29. package/dist/commands/{rm.d.ts → rm.d.mts} +2 -2
  30. package/dist/commands/{rm.js → rm.mjs} +34 -40
  31. package/dist/common/{authenticated-command.js → authenticated-command.mjs} +65 -75
  32. package/dist/common/defaults/{create-component-defaults.js → create-component-defaults.mjs} +2 -7
  33. package/dist/common/{version-control.d.ts → version-control.d.mts} +1 -1
  34. package/dist/common/{version-control.js → version-control.mjs} +170 -202
  35. package/dist/index.js +1 -5
  36. package/dist/{productionCssPlugin.js → productionCssPlugin.mjs} +4 -10
  37. package/dist/{reactShimPlugin.js → reactShimPlugin.mjs} +17 -24
  38. package/dist/util/migrationWarningsForApplications.mjs +47 -0
  39. package/dist/util/{migrationsForDotfiles.js → migrationsForDotfiles.mjs} +10 -17
  40. package/oclif.manifest.json +274 -161
  41. package/package.json +43 -41
  42. package/dist/appendHotReloadEventPlugin.js +0 -48
  43. package/dist/commands/commits.d.ts +0 -18
  44. package/dist/commands/components/register.js +0 -15
  45. package/dist/commands/login.js +0 -61
  46. package/dist/commands/pull.d.ts +0 -17
  47. package/dist/commands/push.d.ts +0 -15
  48. package/dist/util/migrationWarningsForApplications.js +0 -52
  49. /package/dist/{appendHotReloadEventPlugin.d.ts → appendHotReloadEventPlugin.d.mts} +0 -0
  50. /package/dist/common/{authenticated-command.d.ts → authenticated-command.d.mts} +0 -0
  51. /package/dist/common/defaults/{create-component-defaults.d.ts → create-component-defaults.d.mts} +0 -0
  52. /package/dist/{productionCssPlugin.d.ts → productionCssPlugin.d.mts} +0 -0
  53. /package/dist/{reactShimPlugin.d.ts → reactShimPlugin.d.mts} +0 -0
  54. /package/dist/util/{migrationWarningsForApplications.d.ts → migrationWarningsForApplications.d.mts} +0 -0
  55. /package/dist/util/{migrationsForDotfiles.d.ts → migrationsForDotfiles.d.mts} +0 -0
package/dist/index.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
1
+ export { run } from "@oclif/core";
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.productionCssPlugin = void 0;
4
- const tslib_1 = require("tslib");
5
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
1
+ import path from "node:path";
6
2
  // CSS is located at a path like "assets/component-8625163d.css", so
7
3
  // we need to get the full URL to it by using import.meta.url
8
4
  function getInjector(path) {
@@ -17,14 +13,13 @@ function getInjector(path) {
17
13
  // But we want to avoid inline CSS because we can't guarantee components are
18
14
  // all used on the page- so by using <link> tags, the browser does not have to
19
15
  // download unused CSS
20
- const productionCssPlugin = () => {
16
+ export const productionCssPlugin = () => {
21
17
  return {
22
18
  name: "css-reference",
23
19
  enforce: "post",
24
20
  apply: "build",
25
21
  renderChunk(code, chunk) {
26
- var _a;
27
- if ((_a = chunk.viteMetadata) === null || _a === void 0 ? void 0 : _a.importedCss.size) {
22
+ if (chunk.viteMetadata?.importedCss.size) {
28
23
  const cssFiles = Array.from(chunk.viteMetadata.importedCss);
29
24
  if (chunk.isEntry) {
30
25
  return {
@@ -40,7 +35,7 @@ const productionCssPlugin = () => {
40
35
  .map((p) => {
41
36
  // Converts a path like "assets/component-8625163d.css" to
42
37
  // a path like "component-8625163d.css", which resolves as a URL
43
- const relativePath = node_path_1.default.relative(node_path_1.default.dirname(chunk.fileName), p);
38
+ const relativePath = path.relative(path.dirname(chunk.fileName), p);
44
39
  return getInjector(relativePath);
45
40
  })
46
41
  .join("\n")}
@@ -53,4 +48,3 @@ const productionCssPlugin = () => {
53
48
  },
54
49
  };
55
50
  };
56
- exports.productionCssPlugin = productionCssPlugin;
@@ -1,39 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectReactVersionsPlugin = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
- const semver_1 = tslib_1.__importDefault(require("semver"));
8
- const vite_1 = require("vite");
1
+ import path from "path";
2
+ import fs from "fs-extra";
3
+ import semver from "semver";
4
+ import { searchForWorkspaceRoot, mergeConfig, normalizePath, } from "vite";
9
5
  const shimIdForBuild = "injectedReactShim";
10
6
  const shimFileNameDev = `${shimIdForBuild}.jsx`;
11
7
  const shimFileNameBuild = `${shimIdForBuild}.js`;
12
- const pathToInjectedReactShim17 = (0, vite_1.normalizePath)(path_1.default.join(__dirname, `../assets/${shimIdForBuild}17.jsx`));
13
- const pathToInjectedReactShim18 = (0, vite_1.normalizePath)(path_1.default.join(__dirname, `../assets/${shimIdForBuild}18.jsx`));
8
+ const pathToInjectedReactShim17 = normalizePath(path.join(new URL(import.meta.url).pathname, `../../assets/${shimIdForBuild}17.jsx`));
9
+ const pathToInjectedReactShim18 = normalizePath(path.join(new URL(import.meta.url).pathname, `../../assets/${shimIdForBuild}18.jsx`));
14
10
  // This plugin works in both dev and build mode
15
11
  // In dev mode, the UI makes a request to localhost:3002/@superblocksteam/react-shim
16
12
  // In build mode, the plugin injects an additional entry point for the shim
17
- const injectReactVersionsPlugin = () => {
18
- var _a;
19
- const packageJson = fs_extra_1.default.readJsonSync(path_1.default.join((0, vite_1.searchForWorkspaceRoot)(process.cwd()), "package.json"));
20
- if (!((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a.react)) {
13
+ export const injectReactVersionsPlugin = () => {
14
+ const packageJson = fs.readJsonSync(path.join(searchForWorkspaceRoot(process.cwd()), "package.json"));
15
+ if (!packageJson.dependencies?.react) {
21
16
  throw new Error("React is not installed");
22
17
  }
23
- const version = semver_1.default.minVersion(packageJson.dependencies.react);
18
+ const version = semver.minVersion(packageJson.dependencies.react);
24
19
  if (!version)
25
20
  throw new Error("React is not installed");
26
- const isReact17 = semver_1.default.satisfies(version, "^17");
27
- const isReact18 = semver_1.default.satisfies(version, "^18");
21
+ const isReact17 = semver.satisfies(version, "^17");
22
+ const isReact18 = semver.satisfies(version, "^18");
28
23
  return {
29
24
  name: "react-versions-plugin",
30
25
  enforce: "pre",
31
26
  config(config) {
32
- var _a, _b, _c, _d;
33
- config.server = (0, vite_1.mergeConfig)((_a = config.server) !== null && _a !== void 0 ? _a : {}, {
27
+ config.server = mergeConfig(config.server ?? {}, {
34
28
  fs: {
35
29
  allow: [
36
- (0, vite_1.searchForWorkspaceRoot)(process.cwd()),
30
+ searchForWorkspaceRoot(process.cwd()),
37
31
  pathToInjectedReactShim17,
38
32
  pathToInjectedReactShim18,
39
33
  ],
@@ -45,15 +39,15 @@ const injectReactVersionsPlugin = () => {
45
39
  // We can't add `react-dom` because the dependency is `react-dom/client`
46
40
  // for React 18 while it's `react-dom` for React 17. We'd need to detect
47
41
  // what React version the user has installed.
48
- config.optimizeDeps = (0, vite_1.mergeConfig)((_b = config.optimizeDeps) !== null && _b !== void 0 ? _b : {}, {
42
+ config.optimizeDeps = mergeConfig(config.optimizeDeps ?? {}, {
49
43
  include: ["react", "react-dom", "react-dom/client"],
50
44
  });
51
- config.resolve = (0, vite_1.mergeConfig)((_c = config.resolve) !== null && _c !== void 0 ? _c : {}, {
45
+ config.resolve = mergeConfig(config.resolve ?? {}, {
52
46
  dedupe: ["react", "react-dom", "react-dom/client"],
53
47
  });
54
48
  }
55
49
  else if (isReact17) {
56
- config.optimizeDeps = (0, vite_1.mergeConfig)((_d = config.optimizeDeps) !== null && _d !== void 0 ? _d : {}, {
50
+ config.optimizeDeps = mergeConfig(config.optimizeDeps ?? {}, {
57
51
  include: ["react", "react-dom"],
58
52
  });
59
53
  }
@@ -131,4 +125,3 @@ if (import.meta.hot) {
131
125
  },
132
126
  };
133
127
  };
134
- exports.injectReactVersionsPlugin = injectReactVersionsPlugin;
@@ -0,0 +1,47 @@
1
+ import { bold, magenta, red } from "colorette";
2
+ import semver from "semver";
3
+ // If you are changing how application files work on disk, for example changing the directory layout,
4
+ // you need to tell the user how to upgrade manually.
5
+ const BREAKING_APPLICATION_VERSIONS = [
6
+ {
7
+ version: "0.0.20",
8
+ // This is an example message because 0.0.20 does not have a docs page for any migrations. This will be added
9
+ // in a future release
10
+ message: `${red("Warning")}: Your code must be updated due to a breaking change in custom component definitions. See docs.`,
11
+ },
12
+ {
13
+ version: "0.0.21",
14
+ // This is an example message because 0.0.21 does not have a docs page for any migrations. This will be added
15
+ // in a future release
16
+ message: `${red("Error")}: This version of the CLI is incompatible with any Custom Components you've previously used,
17
+ due to breaking changes introduced in the config.ts format and Custom Components React API.
18
+
19
+ ${bold("Your existing components are safe.")}
20
+
21
+ To manually migrate:
22
+
23
+ 1. Rename "eventHandlers" to "events".
24
+ 2. Update your properties to use the new format: ${magenta("https://docs.superblocks.com/applications/custom-components/development-lifecycle#configts")}
25
+ `,
26
+ },
27
+ {
28
+ version: "0.0.23",
29
+ message: `${red("Warning")}: Type definitions for custom components have changed to include null values,
30
+ which were missing from previous types. The previous types were not accurate.
31
+ Superblocks represents missing/undefined properties as null.
32
+
33
+ To manually update, you should follow Typescript errors in your IDE and update your code
34
+ to handle null values.
35
+
36
+ ${bold("Your existing components are safe.")}
37
+
38
+ See changelog: ${magenta("https://github.com/superblocksteam/superblocks-cli/blob/main/CHANGELOG.md")}
39
+ `,
40
+ },
41
+ ];
42
+ export function getWarningsForApplicationMigration(previousVersion, newVersion) {
43
+ const firstBreakingChange = BREAKING_APPLICATION_VERSIONS.find(({ version }) => {
44
+ return (semver.lt(previousVersion, version) && semver.lte(version, newVersion));
45
+ });
46
+ return firstBreakingChange?.message;
47
+ }
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDotfileMigrationNeeded = exports.migrateSuperblocksEntityConfig = exports.migrateSuperblocksMonorepoConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const semver_1 = tslib_1.__importDefault(require("semver"));
1
+ import semver from "semver";
6
2
  // These migrations are used to upgrade the Superblocks config files as needed.
7
3
  // For example if we add a new required field
8
4
  const MonorepoMigratorsFromOldVersion = [
@@ -12,10 +8,9 @@ const MonorepoMigratorsFromOldVersion = [
12
8
  },
13
9
  ];
14
10
  // Recursively migrate configs to the latest version
15
- async function migrateSuperblocksMonorepoConfig(config, options) {
11
+ export async function migrateSuperblocksMonorepoConfig(config, options) {
16
12
  return await sharedMigrator(MonorepoMigratorsFromOldVersion, config, options);
17
13
  }
18
- exports.migrateSuperblocksMonorepoConfig = migrateSuperblocksMonorepoConfig;
19
14
  // These migrations are used to upgrade the Superblocks config files as needed.
20
15
  // For example if we add a new required field
21
16
  const EntityMigratorsFromOldVersion = [
@@ -24,23 +19,21 @@ const EntityMigratorsFromOldVersion = [
24
19
  migrator: (config) => config,
25
20
  },
26
21
  ];
27
- async function migrateSuperblocksEntityConfig(config, options) {
22
+ export async function migrateSuperblocksEntityConfig(config, options) {
28
23
  return await sharedMigrator(EntityMigratorsFromOldVersion, config, options);
29
24
  }
30
- exports.migrateSuperblocksEntityConfig = migrateSuperblocksEntityConfig;
31
- function isDotfileMigrationNeeded(previousVersion, currentVersion) {
25
+ export function isDotfileMigrationNeeded(previousVersion, currentVersion) {
32
26
  return (previousVersion !== currentVersion &&
33
- (MonorepoMigratorsFromOldVersion.some(({ migrateWhenUpgradingTo }) => semver_1.default.gt(migrateWhenUpgradingTo, previousVersion) &&
34
- semver_1.default.lte(migrateWhenUpgradingTo, currentVersion)) ||
35
- EntityMigratorsFromOldVersion.some(({ migrateWhenUpgradingTo }) => semver_1.default.gt(migrateWhenUpgradingTo, previousVersion) &&
36
- semver_1.default.lte(migrateWhenUpgradingTo, currentVersion))));
27
+ (MonorepoMigratorsFromOldVersion.some(({ migrateWhenUpgradingTo }) => semver.gt(migrateWhenUpgradingTo, previousVersion) &&
28
+ semver.lte(migrateWhenUpgradingTo, currentVersion)) ||
29
+ EntityMigratorsFromOldVersion.some(({ migrateWhenUpgradingTo }) => semver.gt(migrateWhenUpgradingTo, previousVersion) &&
30
+ semver.lte(migrateWhenUpgradingTo, currentVersion))));
37
31
  }
38
- exports.isDotfileMigrationNeeded = isDotfileMigrationNeeded;
39
32
  async function sharedMigrator(migratorObject, config, { previousVersion, currentVersion, }) {
40
33
  let newConfig = JSON.parse(JSON.stringify(config));
41
34
  // Find all migrators in the range between previousVersion and currentVersion
42
- const migratorFns = migratorObject.filter(({ migrateWhenUpgradingTo }) => semver_1.default.gt(migrateWhenUpgradingTo, previousVersion) &&
43
- semver_1.default.lte(migrateWhenUpgradingTo, currentVersion));
35
+ const migratorFns = migratorObject.filter(({ migrateWhenUpgradingTo }) => semver.gt(migrateWhenUpgradingTo, previousVersion) &&
36
+ semver.lte(migrateWhenUpgradingTo, currentVersion));
44
37
  migratorFns.forEach(({ migrator, migrateWhenUpgradingTo }) => {
45
38
  try {
46
39
  newConfig = migrator(newConfig);