@superblocksteam/cli 1.9.3 → 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 (59) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +6 -6
  3. package/assets/custom-components/setup/package.json +1 -1
  4. package/assets/custom-components/setup/tsconfig.json +0 -1
  5. package/assets/injectedReactShim17.jsx +15 -0
  6. package/assets/injectedReactShim18.jsx +16 -0
  7. package/assets/injectedReactShimShared.jsx +140 -0
  8. package/bin/dev +5 -7
  9. package/bin/run +1 -3
  10. package/dist/appendHotReloadEventPlugin.d.mts +2 -0
  11. package/dist/appendHotReloadEventPlugin.mjs +43 -0
  12. package/dist/commands/commits.d.mts +18 -0
  13. package/dist/commands/{commits.js → commits.mjs} +59 -67
  14. package/dist/commands/components/{create.d.ts → create.d.mts} +2 -2
  15. package/dist/commands/components/{create.js → create.mjs} +84 -93
  16. package/dist/commands/components/{register.d.ts → register.d.mts} +1 -1
  17. package/dist/commands/components/register.mjs +12 -0
  18. package/dist/commands/components/{upload.d.ts → upload.d.mts} +2 -2
  19. package/dist/commands/components/{upload.js → upload.mjs} +39 -43
  20. package/dist/commands/components/{watch.d.ts → watch.d.mts} +1 -1
  21. package/dist/commands/components/{watch.js → watch.mjs} +29 -36
  22. package/dist/commands/config/{set.d.ts → set.d.mts} +2 -2
  23. package/dist/commands/config/{set.js → set.mjs} +28 -32
  24. package/dist/commands/{init.d.ts → init.d.mts} +4 -4
  25. package/dist/commands/{init.js → init.mjs} +63 -65
  26. package/dist/commands/{login.d.ts → login.d.mts} +1 -1
  27. package/dist/commands/login.mjs +55 -0
  28. package/dist/commands/{migrate.d.ts → migrate.d.mts} +1 -1
  29. package/dist/commands/{migrate.js → migrate.mjs} +38 -46
  30. package/dist/commands/pull.d.mts +17 -0
  31. package/dist/commands/{pull.js → pull.mjs} +74 -80
  32. package/dist/commands/push.d.mts +15 -0
  33. package/dist/commands/{push.js → push.mjs} +81 -90
  34. package/dist/commands/{rm.d.ts → rm.d.mts} +2 -2
  35. package/dist/commands/{rm.js → rm.mjs} +34 -40
  36. package/dist/common/{authenticated-command.js → authenticated-command.mjs} +65 -75
  37. package/dist/common/defaults/{create-component-defaults.js → create-component-defaults.mjs} +2 -7
  38. package/dist/common/{version-control.d.ts → version-control.d.mts} +13 -6
  39. package/dist/common/version-control.mjs +1064 -0
  40. package/dist/index.js +1 -5
  41. package/dist/productionCssPlugin.d.mts +2 -0
  42. package/dist/productionCssPlugin.mjs +50 -0
  43. package/dist/reactShimPlugin.d.mts +2 -0
  44. package/dist/reactShimPlugin.mjs +127 -0
  45. package/dist/util/migrationWarningsForApplications.mjs +47 -0
  46. package/dist/util/{migrationsForDotfiles.js → migrationsForDotfiles.mjs} +10 -17
  47. package/oclif.manifest.json +274 -161
  48. package/package.json +45 -45
  49. package/dist/commands/commits.d.ts +0 -18
  50. package/dist/commands/components/register.js +0 -15
  51. package/dist/commands/login.js +0 -61
  52. package/dist/commands/pull.d.ts +0 -17
  53. package/dist/commands/push.d.ts +0 -15
  54. package/dist/common/version-control.js +0 -716
  55. package/dist/util/migrationWarningsForApplications.js +0 -52
  56. /package/dist/common/{authenticated-command.d.ts → authenticated-command.d.mts} +0 -0
  57. /package/dist/common/defaults/{create-component-defaults.d.ts → create-component-defaults.d.mts} +0 -0
  58. /package/dist/util/{migrationWarningsForApplications.d.ts → migrationWarningsForApplications.d.mts} +0 -0
  59. /package/dist/util/{migrationsForDotfiles.d.ts → migrationsForDotfiles.d.mts} +0 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,87 @@
1
+ Superblocks Community Software License
2
+
3
+ This Superblocks Community License Agreement (the “Agreement”) sets forth the terms on which DayZero
4
+ Software, Inc. d/b/a Superblocks (“Superblocks”) makes available certain software made available by Superblocks
5
+ under this Agreement (the “Software”). BY INSTALLING, DOWNLOADING, ACCESSING, USING OR
6
+ DISTRIBUTING ANY OF THE SOFTWARE, YOU AGREE TO THE TERMS AND CONDITIONS OF THIS
7
+ AGREEMENT.IF YOU DO NOT AGREE TO SUCH TERMS AND CONDITIONS, YOU MUST NOT USE THE
8
+ SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU
9
+ REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE
10
+ TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. “Licensee” means you,
11
+ an individual, or the entity on whose behalf you are receiving the Software.
12
+
13
+ 1. LICENSE GRANT AND CONDITIONS.
14
+
15
+ 1.1 License. Subject to the terms and conditions of this Agreement, Superblocks hereby grants to Licensee a
16
+ non-exclusive, royalty-free, worldwide, non-transferable, non-sublicenseable license during the term of this
17
+ Agreement to: (a) use the Software; (b) prepare modifications and derivative works of the Software; (c)
18
+ distribute the Software (including without limitation in source code or object code form); and (d) reproduce
19
+ copies of the Software (the “License”). Licensee is not granted the right to, and Licensee shall not, exercise the
20
+ License for an Excluded Purpose. For purposes of this Agreement, “Excluded Purpose” means making
21
+ available any software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar online
22
+ service that competes with Superblocks’ products or services.
23
+
24
+ 1.2 Conditions. In consideration of the License, Licensee’s distribution of the Software is subject to the
25
+ following conditions:
26
+
27
+ a. Licensee must cause any Software modified by Licensee to carry prominent notices stating that Licensee
28
+ modified the Software.
29
+ b. On each Software copy, Licensee shall reproduce and not remove or alter all Superblocks or third party
30
+ copyright or other proprietary notices contained in the Software, and Licensee must provide the notice
31
+ below with each copy.
32
+
33
+ “This software is made available by DayZero Software, Inc. d/b/a Superblocks, under the terms of the
34
+ Superblocks Community License Agreement. © 2022 DayZero Software, Inc.”
35
+
36
+ 1.3 Licensee Modifications. Licensee may add its own copyright notices to modifications made by Licensee
37
+ and may provide additional or different license terms and conditions for use, reproduction, or distribution of
38
+ Licensee’s modifications. While redistributing the Software or modifications thereof, Licensee may choose to
39
+ offer, for a fee or free of charge, support, warranty, indemnity, or other obligations. Licensee, and not
40
+ Superblocks, will be responsible for any such obligations.
41
+
42
+ 1.4 No Sublicensing. The License does not include the right to sublicense the Software, however, each recipient
43
+ to which Licensee provides the Software may exercise the Licenses so long as such recipient agrees to the terms
44
+ and conditions of this Agreement.
45
+
46
+ 2. TERM AND TERMINATION. This Agreement will continue unless and until earlier terminated as set forth
47
+ herein. If Licensee breaches any of its conditions or obligations under this Agreement, this Agreement will
48
+ terminate automatically and the License will terminate automatically and permanently.
49
+
50
+ 3. INTELLECTUAL PROPERTY. As between the parties, Superblocks will retain all right, title, and interest in
51
+ the Software, and all intellectual property rights therein. Superblocks hereby reserves all rights not expressly
52
+ granted to Licensee in this Agreement. Superblocks hereby reserves all rights in its trademarks and service
53
+ marks, and no licenses therein are granted in this Agreement.
54
+
55
+ 4. DISCLAIMER. SUPERBLOCKS HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND
56
+ CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY
57
+ DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
58
+ PURPOSE, WITH RESPECT TO THE SOFTWARE.
59
+
60
+ 5. LIMITATION OF LIABILITY. SUPERBLOCKS WILL NOT BE LIABLE FOR ANY DAMAGES OF
61
+ ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL,
62
+ SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY
63
+ THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT. THE FOREGOING SHALL APPLY TO
64
+ THE EXTENT PERMITTED BY APPLICABLE LAW.
65
+
66
+ 6. GENERAL.
67
+
68
+ 6.1  Governing Law. This Agreement will be governed by and interpreted in accordance with the laws of the
69
+ state of California, without reference to its conflict of laws principles. If Licensee is located within the United
70
+ States, all disputes arising out of this Agreement are subject to the exclusive jurisdiction of courts located in San
71
+ Mateo County, California. USA. If Licensee is located outside of the United States, any dispute, controversy or
72
+ claim arising out of or relating to this Agreement will be referred to and finally determined by arbitration in
73
+ accordance with the JAMS International Arbitration Rules. The tribunal will consist of one neutral arbitrator.
74
+ The place of arbitration will be Palo Alto, California. The language to be used in the arbitral proceedings will be
75
+ English. Judgment upon the award rendered by the arbitrator may be entered in any court having jurisdiction
76
+ thereof.
77
+
78
+ 6.2.  Assignment. Licensee may not assign its rights under this Agreement to any third party. Superblocks may
79
+ freely assign its rights under this Agreement to any third party.
80
+
81
+ 6.3.  Other.  This Agreement is the entire agreement between the parties regarding the subject matter hereof.
82
+ No amendment or modification of this Agreement will be valid or binding upon the parties unless made in
83
+ writing and signed by the duly authorized representatives of both parties. In the event that any provision,
84
+ including without limitation any condition, of this Agreement is held to be unenforceable, this Agreement and
85
+ all licenses and rights granted hereunder will immediately terminate. Waiver by Superblocks of a breach of any
86
+ provision of this Agreement or the failure by Superblocks to exercise any right hereunder will not be construed
87
+ as a waiver of any subsequent breach of that right or as a waiver of any other right.
package/README.md CHANGED
@@ -12,7 +12,7 @@ $ npm install -g @superblocksteam/cli
12
12
  $ superblocks COMMAND
13
13
  running command...
14
14
  $ superblocks (--version)
15
- @superblocksteam/cli/1.9.3 linux-x64 node-v20.18.2
15
+ @superblocksteam/cli/1.12.0 linux-x64 node-v20.19.0
16
16
  $ superblocks --help [COMMAND]
17
17
  USAGE
18
18
  $ superblocks COMMAND
@@ -27,7 +27,7 @@ USAGE
27
27
  * [`superblocks components upload`](#superblocks-components-upload)
28
28
  * [`superblocks components watch`](#superblocks-components-watch)
29
29
  * [`superblocks config set PROPERTY VALUE`](#superblocks-config-set-property-value)
30
- * [`superblocks help [COMMANDS]`](#superblocks-help-commands)
30
+ * [`superblocks help [COMMAND]`](#superblocks-help-command)
31
31
  * [`superblocks init [RESOURCE_URL]`](#superblocks-init-resource_url)
32
32
  * [`superblocks login`](#superblocks-login)
33
33
  * [`superblocks migrate`](#superblocks-migrate)
@@ -150,16 +150,16 @@ EXAMPLES
150
150
  $ superblocks config set domain app.superblocks.com
151
151
  ```
152
152
 
153
- ## `superblocks help [COMMANDS]`
153
+ ## `superblocks help [COMMAND]`
154
154
 
155
155
  Display help for superblocks.
156
156
 
157
157
  ```
158
158
  USAGE
159
- $ superblocks help [COMMANDS] [-n]
159
+ $ superblocks help [COMMAND...] [-n]
160
160
 
161
161
  ARGUMENTS
162
- COMMANDS Command to show help for.
162
+ COMMAND... Command to show help for.
163
163
 
164
164
  FLAGS
165
165
  -n, --nested-commands Include all nested commands in the output.
@@ -168,7 +168,7 @@ DESCRIPTION
168
168
  Display help for superblocks.
169
169
  ```
170
170
 
171
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.16/src/commands/help.ts)_
171
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.26/src/commands/help.ts)_
172
172
 
173
173
  ## `superblocks init [RESOURCE_URL]`
174
174
 
@@ -7,7 +7,7 @@
7
7
  "lint:fix": "npx eslint . --fix"
8
8
  },
9
9
  "dependencies": {
10
- "@superblocksteam/custom-components": "1.9.3",
10
+ "@superblocksteam/custom-components": "1.10.0",
11
11
  "react": "^18",
12
12
  "react-dom": "^18"
13
13
  },
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "noEmit": true,
4
- "importHelpers": true,
5
4
  "module": "CommonJS",
6
5
  "strict": true,
7
6
  "target": "es2019",
@@ -0,0 +1,15 @@
1
+ import React, { createElement } from "react";
2
+ import ReactDOM from "react-dom";
3
+ import { setRenderHelper, registerPortal, removePortal } from "./injectedReactShimShared";
4
+
5
+ let isLoaded = false;
6
+
7
+ export function loadReact(rootEl) {
8
+ setRenderHelper((component) => ReactDOM.render(component, rootEl));
9
+ if (!isLoaded) {
10
+ ReactDOM.render(createElement(React.Fragment), rootEl);
11
+ isLoaded = true;
12
+ }
13
+
14
+ return { registerPortal, removePortal, React };
15
+ };
@@ -0,0 +1,16 @@
1
+ import React, { createElement } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { setRenderHelper, registerPortal, removePortal } from "./injectedReactShimShared";
4
+
5
+ let isLoaded = false;
6
+
7
+ export function loadReact(rootEl) {
8
+ if (!isLoaded) {
9
+ const root = createRoot(rootEl);
10
+ root.render(createElement(React.Fragment));
11
+ setRenderHelper((component) => root.render(component));
12
+ isLoaded = true;
13
+ }
14
+
15
+ return { registerPortal, removePortal, React };
16
+ };
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Detect and support multiple React version
3
+ * this file is served by the user's code
4
+ */
5
+ import React, { createElement } from "react";
6
+ import { createPortal } from "react-dom";
7
+
8
+ let renderHelper;
9
+ export function setRenderHelper(helper) {
10
+ renderHelper = helper;
11
+ }
12
+
13
+ /** @type Array<React.ReactPortal> */
14
+ const portals = new Map();
15
+
16
+ export function registerPortal(
17
+ Component,
18
+ props,
19
+ element,
20
+ ccRenderingContext,
21
+ SuperblocksCCReactContext
22
+ ) {
23
+ if (!ccRenderingContext)
24
+ throw new TypeError("ccRenderingContext is required");
25
+ const portal = createPortal(
26
+ <SuperblocksCCReactContext.Provider value={ccRenderingContext}>
27
+ <CustomComponentErrorBoundary componentRef={Component}>
28
+ <Component {...props} />
29
+ </CustomComponentErrorBoundary>
30
+ </SuperblocksCCReactContext.Provider>,
31
+ element,
32
+ ccRenderingContext.widgetId
33
+ );
34
+ portals.set(ccRenderingContext.widgetId, portal);
35
+ renderHelper(
36
+ createElement(React.Fragment, null, Array.from(portals.values()))
37
+ );
38
+ }
39
+ export function removePortal(key) {
40
+ portals.delete(key);
41
+ renderHelper(
42
+ createElement(React.Fragment, null, Array.from(portals.values()))
43
+ );
44
+ }
45
+
46
+ class CustomComponentErrorBoundary extends React.Component {
47
+ constructor(props) {
48
+ super(props);
49
+ this.state = { hasError: false, errorDisplay: null };
50
+ }
51
+
52
+ static getDerivedStateFromError(error) {
53
+ // Update state so the next render will show the fallback UI.
54
+ const errorDisplay = error ?? null;
55
+ return { hasError: true, errorDisplay };
56
+ }
57
+
58
+ componentDidCatch(error) {
59
+ console.error(error);
60
+ }
61
+
62
+ componentDidUpdate(prevProps) {
63
+ if (prevProps.componentRef !== this.props.componentRef) {
64
+ // Clear error boundary if component is changed
65
+ this.setState({ hasError: false, errorDisplay: null });
66
+ }
67
+ }
68
+
69
+ render() {
70
+ return (
71
+ <div
72
+ style={{
73
+ height: "100%",
74
+ width: "100%",
75
+ }}
76
+ >
77
+ {this.state.hasError && this.state.errorDisplay ? (
78
+ <div
79
+ style={{
80
+ height: "100%",
81
+ width: "100%",
82
+ backgroundColor: "white",
83
+ display: "flex",
84
+ flexDirection: "column",
85
+ justifyContent: "center",
86
+ alignItems: "center",
87
+ textAlign: "center",
88
+ borderRadius: "4px",
89
+ border: "1px solid #F45252",
90
+ }}
91
+ >
92
+ <p>
93
+ <span
94
+ style={{
95
+ display: "inline-block",
96
+ cursor: "pointer",
97
+ color: "#29bbff",
98
+ }}
99
+ role="button"
100
+ tabIndex={0}
101
+ onClick={() => {
102
+ this.setState({ hasError: false, errorDisplay: null });
103
+ }}
104
+ >
105
+ &#8635; Reload component
106
+ </span>{" "}
107
+ </p>
108
+ <p>
109
+ <span
110
+ style={{
111
+ display: "inline-block",
112
+ cursor: "pointer",
113
+ color: "#F45252",
114
+ textDecorationLine: "underline",
115
+ }}
116
+ role="button"
117
+ tabIndex={1}
118
+ onClick={() => {
119
+ const errorEvent = new CustomEvent("cc-error-display", {
120
+ detail: {
121
+ stack: this.state.errorDisplay?.stack,
122
+ message: this.state.errorDisplay?.message,
123
+ },
124
+ });
125
+ window.dispatchEvent(errorEvent);
126
+ }}
127
+ >
128
+ &#10071; View Error
129
+ </span>
130
+ </p>
131
+ </div>
132
+ ) : (
133
+ this.props.children
134
+ )}
135
+ </div>
136
+ );
137
+ }
138
+ }
139
+
140
+ export { CustomComponentErrorBoundary };
package/bin/dev CHANGED
@@ -1,8 +1,6 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env ts-node
2
2
 
3
- // eslint-disable-next-line node/shebang
4
- (async () => {
5
- const oclif = await import("@oclif/core");
6
- // eslint-disable-next-line unicorn/prefer-module
7
- await oclif.execute({ type: "cjs", development: true, dir: __dirname });
8
- })();
3
+ ;(async () => {
4
+ const oclif = await import('@oclif/core')
5
+ await oclif.execute({development: true, dir: __dirname})
6
+ })()
package/bin/run CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // eslint-disable-next-line node/shebang
4
3
  (async () => {
5
4
  const oclif = await import("@oclif/core");
6
- // eslint-disable-next-line unicorn/prefer-module
7
- await oclif.execute({ type: "cjs", dir: __dirname });
5
+ await oclif.execute({ dir: __dirname });
8
6
  })();
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "vite";
2
+ export declare const appendHotReloadEventPlugin: (getBranch: () => Promise<string | null>) => Plugin;
@@ -0,0 +1,43 @@
1
+ import path from "path";
2
+ import { SuperblocksSdk } from "@superblocksteam/sdk";
3
+ import { getSuperblocksApplicationConfigJson, getComponentConfigs, getLocalTokenWithUrl, COMPONENT_EVENT_HEADER, ComponentEvent, getSuperblocksMonorepoConfigJson, } from "@superblocksteam/util";
4
+ export const appendHotReloadEventPlugin = (getBranch) => {
5
+ return {
6
+ name: "append-code-plugin",
7
+ enforce: "pre",
8
+ apply: "serve", // Apply this plugin only during development (dev server)
9
+ async handleHotUpdate(ctx) {
10
+ const isConfigFile = path.basename(ctx.file) === "config.ts";
11
+ if (!isConfigFile)
12
+ return;
13
+ try {
14
+ const result = await getLocalTokenWithUrl();
15
+ if (!result || !("token" in result)) {
16
+ throw new Error("Please run `superblocks login` to login.");
17
+ }
18
+ const { token, superblocksBaseUrl } = result;
19
+ const resourceConfig = await getSuperblocksApplicationConfigJson();
20
+ const { configs, hasError } = await getComponentConfigs(true);
21
+ if (hasError)
22
+ return;
23
+ const [rootSettings] = await getSuperblocksMonorepoConfigJson(true);
24
+ const sdk = new SuperblocksSdk(token, superblocksBaseUrl, rootSettings.metadata.cliVersion);
25
+ console.log("Registering components...");
26
+ const branch = await getBranch();
27
+ const headers = {
28
+ [COMPONENT_EVENT_HEADER]: ComponentEvent.REGISTER,
29
+ };
30
+ await sdk.registerComponents(resourceConfig.id, configs, branch, headers);
31
+ console.log("Re-registered components!");
32
+ ctx.server.ws.send({
33
+ type: "custom",
34
+ event: "config-reloaded",
35
+ data: {},
36
+ });
37
+ }
38
+ catch (e) {
39
+ console.error(e.message);
40
+ }
41
+ },
42
+ };
43
+ };
@@ -0,0 +1,18 @@
1
+ import { GetCommitsResponseBody } from "@superblocksteam/sdk";
2
+ import { AuthenticatedCommand } from "../common/authenticated-command.mjs";
3
+ export default class Commits extends AuthenticatedCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
9
+ offset: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ static args: {
12
+ resource_path: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<void>;
15
+ private createTasks;
16
+ private getResourceIdToShowCommits;
17
+ printCommits(commits: GetCommitsResponseBody, branch?: string): void;
18
+ }