@embeddable.com/init 0.1.1 → 0.1.3

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 (2) hide show
  1. package/dist/index.js +40 -15
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import chalk from "chalk";
8
8
  import degit from "degit";
9
9
  import prompts from "prompts";
10
10
  import terminalLink from "terminal-link";
11
+ import open from "open";
11
12
  var REPO_URL = "embeddable-hq/remarkable-pro-boilerplate";
12
13
  var DEFAULT_FOLDER = "embeddable-repo";
13
14
  var WORKSPACE_URLS = {
@@ -19,6 +20,12 @@ function exit(message) {
19
20
  if (message) console.log(message);
20
21
  process.exit(0);
21
22
  }
23
+ function printDocsHint() {
24
+ const docsUrl = "https://docs.embeddable.com";
25
+ const docsLink = terminalLink(docsUrl, docsUrl, { fallback: (text) => text });
26
+ console.log(`If you get stuck, please follow our 'Quick-start guide' at ${chalk.cyan(docsLink)}
27
+ `);
28
+ }
22
29
  function validateFolderName(value, cwd) {
23
30
  const trimmed = value.trim();
24
31
  if (!trimmed) return "Folder name is required";
@@ -37,10 +44,20 @@ function isValidUuid(value) {
37
44
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
38
45
  return uuidRegex.test(value.trim());
39
46
  }
47
+ var LOGO = `
48
+ \u2584\u2584\u2588\u2588\u2588\u2588\u2584\u2584
49
+ \u2584\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u2588\u2584 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
50
+ \u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
51
+ \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557
52
+ \u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D
53
+ \u2580\u2588\u2588\u2584\u2584\u2584\u2584\u2584\u2584\u2588\u2588\u2580 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
54
+ \u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580 \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
55
+ `;
40
56
  async function main() {
41
57
  const onCancel = () => exit("\nSetup cancelled.\n");
42
- console.log(chalk.bold("\nWelcome to Embeddable!\n"));
43
- console.log(`Embeddable stores your ${chalk.bold("charting components")}, ${chalk.bold("data models")} and ${chalk.bold("themes")} in code, so you have full control over the look-and-feel and the data powering your dashboards.
58
+ console.log(chalk.white(LOGO));
59
+ console.log(chalk.bold("Welcome to Embeddable!\n"));
60
+ console.log(`Embeddable stores your ${chalk.bold("charting components")}, ${chalk.bold("data models")} and ${chalk.bold("themes")} in code, so you have ${chalk.bold("full control")} over the ${chalk.bold("look-and-feel")} and the ${chalk.bold("data")} powering your dashboards.
44
61
  `);
45
62
  console.log("This tool helps you get set up to create your first Embeddable dashboard.\n");
46
63
  const cwd = process.cwd();
@@ -82,6 +99,7 @@ async function main() {
82
99
  console.error(chalk.red(`
83
100
  Failed to download boilerplate: ${message}
84
101
  `));
102
+ printDocsHint();
85
103
  process.exit(1);
86
104
  }
87
105
  try {
@@ -95,16 +113,20 @@ Failed to download boilerplate: ${message}
95
113
  try {
96
114
  execSync("npm install", { cwd: projectPath, stdio: "inherit" });
97
115
  } catch {
98
- console.log(
99
- chalk.yellow("\nWarning: npm install failed. You can run it manually.")
100
- );
116
+ console.error(chalk.red("\nnpm install failed.\n"));
117
+ printDocsHint();
118
+ process.exit(1);
101
119
  }
120
+ console.log(`
121
+ `);
102
122
  const { apiKey } = await prompts(
103
123
  {
104
124
  type: "password",
105
125
  name: "apiKey",
106
- message: `
107
- Grab your API key (to create an account, head to ${chalk.cyan("https://embeddable.com/select-region")}) and paste it here:`,
126
+ message: `You'll need an API Key to push this code bundle to your workspace
127
+ (to create an account, head to ${chalk.cyan("https://embeddable.com/start")}).
128
+
129
+ Paste your API Key here:`,
108
130
  validate: (value) => {
109
131
  const trimmed = value.trim();
110
132
  if (!trimmed) return "API key is required";
@@ -120,6 +142,7 @@ Grab your API key (to create an account, head to ${chalk.cyan("https://embeddabl
120
142
  const embeddableDir = path.join(projectPath, ".embeddable");
121
143
  fs.mkdirSync(embeddableDir, { recursive: true });
122
144
  fs.writeFileSync(path.join(embeddableDir, ".api-key"), apiKey.trim());
145
+ console.log("");
123
146
  const regionResponse = await prompts(
124
147
  {
125
148
  type: "select",
@@ -166,20 +189,20 @@ Grab your API key (to create an account, head to ${chalk.cyan("https://embeddabl
166
189
  try {
167
190
  execSync("npm run embeddable:build", { cwd: projectPath, stdio: "inherit" });
168
191
  } catch {
169
- console.log(
170
- chalk.yellow("\nWarning: embeddable:build failed. You can run it manually.")
171
- );
192
+ console.error(chalk.red("\nFailed to build bundle.\n"));
193
+ printDocsHint();
194
+ process.exit(1);
172
195
  }
173
- console.log(chalk.dim("\nPushing to workspace...\n"));
196
+ console.log(chalk.dim("\nPushing bundle to workspace...\n"));
174
197
  try {
175
198
  execSync(
176
199
  `npm run embeddable:push -- --api-key ${apiKey.trim()} --email "no-reply@embeddable.com" --message "npx @embeddable.com/init"`,
177
200
  { cwd: projectPath, stdio: "inherit" }
178
201
  );
179
202
  } catch {
180
- console.log(
181
- chalk.yellow("\nWarning: embeddable:push failed. You can run it manually.")
182
- );
203
+ console.error(chalk.red("\nFailed to push bundle to workspace.\n"));
204
+ printDocsHint();
205
+ process.exit(1);
183
206
  }
184
207
  const workspaceUrl = WORKSPACE_URLS[region];
185
208
  const workspaceLink = terminalLink(workspaceUrl, workspaceUrl, {
@@ -193,12 +216,14 @@ Grab your API key (to create an account, head to ${chalk.cyan("https://embeddabl
193
216
  Success!
194
217
  `));
195
218
  console.log(`You have pushed your ${chalk.bold("components")} and ${chalk.bold("data models")} to workspace.`);
196
- console.log(`Head there now to build your first Embeddable: ${chalk.cyan(workspaceLink)}
219
+ console.log(`Refresh your workspace page to see the "Create new Embeddable" button and the sample dashboards: ${chalk.cyan(workspaceLink)}
197
220
  `);
198
221
  console.log(`Follow the guide here to create your first Embeddable dashboard: ${chalk.cyan(docsLink)}
199
222
  `);
223
+ await open(workspaceUrl);
200
224
  }
201
225
  main().catch((error) => {
202
226
  console.error(chalk.red("An unexpected error occurred:"), error);
227
+ printDocsHint();
203
228
  process.exit(1);
204
229
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/init",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI tool for Embeddable",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,6 +25,7 @@
25
25
  "dependencies": {
26
26
  "chalk": "^5.3.0",
27
27
  "degit": "^2.8.4",
28
+ "open": "^11.0.0",
28
29
  "prompts": "^2.4.2",
29
30
  "terminal-link": "^5.0.0"
30
31
  },