juo 0.0.2-pre.1 → 0.2.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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g juo
20
20
  $ juo COMMAND
21
21
  running command...
22
22
  $ juo (--version)
23
- juo/0.0.2-pre.1 darwin-arm64 node-v22.13.1
23
+ juo/0.2.0 linux-x64 node-v22.21.0
24
24
  $ juo --help [COMMAND]
25
25
  USAGE
26
26
  $ juo COMMAND
@@ -1,11 +1,11 @@
1
1
  import debug from "debug";
2
2
 
3
3
  //#region src/utils/config.ts
4
- const MIXPANEL_TOKEN = "";
5
- const MIXPANEL_API_URL = "https://api.mixpanel.com";
6
- const CUSTOMERIO_BETA_FORM_URL = "";
7
- const CUSTOMERIO_SITE_ID = "";
8
- const CUSTOMERIO_API_KEY = "";
4
+ const MIXPANEL_TOKEN = "919dd811a5e2137983cc8fc304b8584b";
5
+ const MIXPANEL_API_URL = "https://api-eu.mixpanel.com";
6
+ const CUSTOMERIO_BETA_FORM_URL = "https://track-cio.juo.io/api/v1/forms/3c02106b-9746-4ebe-a116-553e47494eb4/submit";
7
+ const CUSTOMERIO_SITE_ID = "60da89062ce61084fc27";
8
+ const CUSTOMERIO_API_KEY = "1d54688e66cddda9ea72";
9
9
 
10
10
  //#endregion
11
11
  //#region src/utils/analytics.ts
@@ -1,13 +1,13 @@
1
1
  import { Command } from "@oclif/core";
2
- import * as _oclif_core_interfaces5 from "@oclif/core/interfaces";
2
+ import * as _oclif_core_interfaces1 from "@oclif/core/interfaces";
3
3
 
4
4
  //#region src/commands/create.d.ts
5
5
  declare class Create extends Command {
6
6
  static description: string;
7
7
  static flags: {
8
- quickstart: _oclif_core_interfaces5.BooleanFlag<boolean>;
9
- storybook: _oclif_core_interfaces5.BooleanFlag<boolean>;
10
- verbose: _oclif_core_interfaces5.BooleanFlag<boolean>;
8
+ quickstart: _oclif_core_interfaces1.BooleanFlag<boolean>;
9
+ storybook: _oclif_core_interfaces1.BooleanFlag<boolean>;
10
+ verbose: _oclif_core_interfaces1.BooleanFlag<boolean>;
11
11
  };
12
12
  run(): Promise<void>;
13
13
  private getProjectConfig;
@@ -1,6 +1,6 @@
1
- import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-C0le5FdK.js";
2
- import { t as PackageGenerator } from "../packageGenerator-8E_-V5CL.js";
3
- import { t as Generate } from "../generate-Be3Ctuvv.js";
1
+ import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-Ug40Yo7e.js";
2
+ import { t as PackageGenerator } from "../packageGenerator-Dno-ecHh.js";
3
+ import { t as Generate } from "../generate-D9WUAwYz.js";
4
4
  import { Command, Flags } from "@oclif/core";
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import path from "node:path";
@@ -20,7 +20,7 @@ var ConfigFilesGenerator = class extends BaseTemplateGenerator {
20
20
  //#region src/utils/storybookGenerator.ts
21
21
  const COMMAND_CONFIG = {
22
22
  npm: "npx",
23
- pnpm: "pnpx",
23
+ pnpm: "pnpm dlx",
24
24
  yarn: "yarn dlx"
25
25
  };
26
26
  var StorybookGenerator = class extends BaseTemplateGenerator {
@@ -274,7 +274,6 @@ var Create = class Create extends Command {
274
274
  process.chdir(originalCwd);
275
275
  }
276
276
  outro(`Run \`cd ${packageName}\` to start developing your project.`);
277
- process.exit(0);
278
277
  }
279
278
  async getProjectConfig(quickstart, storybookFlag) {
280
279
  if (quickstart) return {
@@ -293,7 +292,7 @@ var Create = class Create extends Command {
293
292
  if (!/^[a-z0-9-]+$/.test(value)) return `Invalid package name`;
294
293
  }
295
294
  });
296
- if (isCancel(packageName)) process.exit(0);
295
+ if (isCancel(packageName)) this.exit(0);
297
296
  const packageManager = await select({
298
297
  initialValue: "npm",
299
298
  message: "What package manager to use?",
@@ -312,7 +311,7 @@ var Create = class Create extends Command {
312
311
  }
313
312
  ]
314
313
  });
315
- if (isCancel(packageManager)) process.exit(0);
314
+ if (isCancel(packageManager)) this.exit(0);
316
315
  const framework = await select({
317
316
  initialValue: "react",
318
317
  message: "What framework to use?",
@@ -324,7 +323,7 @@ var Create = class Create extends Command {
324
323
  value: "preact"
325
324
  }]
326
325
  });
327
- if (isCancel(framework)) process.exit();
326
+ if (isCancel(framework)) this.exit(0);
328
327
  const tailwind = await select({
329
328
  initialValue: true,
330
329
  message: "Do you want to use Tailwind CSS?",
@@ -336,14 +335,14 @@ var Create = class Create extends Command {
336
335
  value: false
337
336
  }]
338
337
  });
339
- if (isCancel(tailwind)) process.exit(0);
338
+ if (isCancel(tailwind)) this.exit(0);
340
339
  let storybook;
341
340
  if (storybookFlag === void 0) {
342
341
  const storybookAnswer = await confirm({
343
342
  initialValue: false,
344
343
  message: "Do you want Storybook?"
345
344
  });
346
- if (isCancel(storybookAnswer)) process.exit(0);
345
+ if (isCancel(storybookAnswer)) this.exit(0);
347
346
  storybook = storybookAnswer;
348
347
  } else storybook = storybookFlag;
349
348
  return {
@@ -1,15 +1,15 @@
1
1
  import { Command } from "@oclif/core";
2
- import * as _oclif_core_interfaces0 from "@oclif/core/interfaces";
2
+ import * as _oclif_core_interfaces4 from "@oclif/core/interfaces";
3
3
 
4
4
  //#region src/commands/generate.d.ts
5
5
  declare class Generate extends Command {
6
6
  static description: string;
7
7
  static examples: string[];
8
8
  static flags: {
9
- name: _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
10
- tailwind: _oclif_core_interfaces0.BooleanFlag<boolean>;
11
- type: _oclif_core_interfaces0.OptionFlag<string, _oclif_core_interfaces0.CustomOptions>;
12
- verbose: _oclif_core_interfaces0.BooleanFlag<boolean>;
9
+ name: _oclif_core_interfaces4.OptionFlag<string | undefined, _oclif_core_interfaces4.CustomOptions>;
10
+ tailwind: _oclif_core_interfaces4.BooleanFlag<boolean>;
11
+ type: _oclif_core_interfaces4.OptionFlag<string, _oclif_core_interfaces4.CustomOptions>;
12
+ verbose: _oclif_core_interfaces4.BooleanFlag<boolean>;
13
13
  };
14
14
  static id: string;
15
15
  run(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import "../juoTemplateGenerator-C0le5FdK.js";
2
- import { t as Generate } from "../generate-Be3Ctuvv.js";
1
+ import "../juoTemplateGenerator-Ug40Yo7e.js";
2
+ import { t as Generate } from "../generate-D9WUAwYz.js";
3
3
 
4
4
  export { Generate as default };
@@ -1,10 +1,11 @@
1
1
  import { Command, Interfaces } from "@oclif/core";
2
- import * as _oclif_core_interfaces8 from "@oclif/core/interfaces";
2
+ import * as _oclif_core_interfaces0 from "@oclif/core/interfaces";
3
3
 
4
4
  //#region src/base-command.d.ts
5
5
  interface BaseConfig {
6
6
  JUO_API_KEY: string;
7
7
  JUO_API_URL: string;
8
+ JUO_TENANT_ID?: string;
8
9
  }
9
10
  type Flags$1<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
10
11
  type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
@@ -18,6 +19,7 @@ declare abstract class BaseCommand<T extends typeof Command> extends Command {
18
19
  protected get configFilePath(): string;
19
20
  protected configExists(): boolean;
20
21
  protected ensureConfig(reconfigure?: boolean): Promise<BaseConfig>;
22
+ protected ensureTenantId(): Promise<string>;
21
23
  init(): Promise<void>;
22
24
  protected loadConfig(): Partial<BaseConfig>;
23
25
  protected saveConfig(config: Partial<BaseConfig>): void;
@@ -30,7 +32,7 @@ declare class Publish extends BaseCommand<typeof Publish> {
30
32
  static description: string;
31
33
  static examples: string[];
32
34
  static flags: {
33
- theme: _oclif_core_interfaces8.OptionFlag<string, _oclif_core_interfaces8.CustomOptions>;
35
+ theme: _oclif_core_interfaces0.OptionFlag<string, _oclif_core_interfaces0.CustomOptions>;
34
36
  };
35
37
  getAllFiles(dirPath: string, basePath: string): string[];
36
38
  run(): Promise<void>;
@@ -66,6 +66,25 @@ var BaseCommand = class extends Command {
66
66
  if (this.validateConfig(config)) return config;
67
67
  throw new Error("Failed to create valid configuration");
68
68
  }
69
+ async ensureTenantId() {
70
+ let config = {};
71
+ if (this.configExists()) try {
72
+ config = this.loadConfig();
73
+ if (config.JUO_TENANT_ID?.trim()) return config.JUO_TENANT_ID.trim();
74
+ } catch {}
75
+ const tenantId = (await inquirer.prompt([{
76
+ message: "Enter your tenant ID (shop identifier):",
77
+ name: "JUO_TENANT_ID",
78
+ type: "input",
79
+ validate(input) {
80
+ if (!input.trim()) return "Tenant ID is required";
81
+ return true;
82
+ }
83
+ }])).JUO_TENANT_ID.trim().replace(/\.myshopify\.com$/, "");
84
+ config.JUO_TENANT_ID = tenantId;
85
+ this.saveConfig(config);
86
+ return tenantId;
87
+ }
69
88
  async init() {
70
89
  await super.init();
71
90
  const { args, flags } = await this.parse({
@@ -1,4 +1,4 @@
1
- import { t as JuoTemplateGenerator } from "./juoTemplateGenerator-C0le5FdK.js";
1
+ import { t as JuoTemplateGenerator } from "./juoTemplateGenerator-Ug40Yo7e.js";
2
2
  import { Command, Flags } from "@oclif/core";
3
3
  import { existsSync } from "node:fs";
4
4
  import path from "node:path";
@@ -1,9 +1,12 @@
1
- import { a as CUSTOMERIO_BETA_FORM_URL, i as CUSTOMERIO_API_KEY, n as trackCommandCompleted, o as CUSTOMERIO_SITE_ID, t as trackBetaSignup } from "../analytics-CyANz2YH.js";
1
+ import { a as CUSTOMERIO_BETA_FORM_URL, i as CUSTOMERIO_API_KEY, n as trackCommandCompleted, o as CUSTOMERIO_SITE_ID, t as trackBetaSignup } from "../analytics-CgHTVQWO.js";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import path from "node:path";
2
4
  import { confirm, isCancel, text } from "@clack/prompts";
3
5
  import debug from "debug";
4
6
 
5
7
  //#region src/utils/betaSignup.ts
6
8
  const log$1 = debug("juo:betaSignup");
9
+ let promptedThisSession = false;
7
10
  async function sendToCustomerIO(email) {
8
11
  if (!CUSTOMERIO_BETA_FORM_URL || !CUSTOMERIO_SITE_ID || !CUSTOMERIO_API_KEY) return;
9
12
  try {
@@ -25,12 +28,36 @@ async function sendToCustomerIO(email) {
25
28
  log$1("Error sending beta signup to CustomerIO: %O", error);
26
29
  }
27
30
  }
28
- async function promptBetaSignup(commandContext) {
31
+ function getBetaSignupStatePath(configDir) {
32
+ return path.join(configDir, "beta-signup.json");
33
+ }
34
+ function hasUserRespondedToBetaSignup(configDir) {
35
+ try {
36
+ const statePath = getBetaSignupStatePath(configDir);
37
+ if (!existsSync(statePath)) return false;
38
+ return JSON.parse(readFileSync(statePath, "utf8")).responded === true;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ function markUserRespondedToBetaSignup(configDir) {
44
+ try {
45
+ if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true });
46
+ writeFileSync(getBetaSignupStatePath(configDir), JSON.stringify({ responded: true }), "utf8");
47
+ } catch (error) {
48
+ log$1("Failed to persist beta signup state: %O", error);
49
+ }
50
+ }
51
+ async function promptBetaSignup(commandContext, configDir) {
52
+ if (promptedThisSession) return;
53
+ if (hasUserRespondedToBetaSignup(configDir)) return;
54
+ promptedThisSession = true;
29
55
  try {
30
56
  const shouldSignup = await confirm({
31
57
  initialValue: true,
32
58
  message: "Would you like to request access to the private beta?"
33
59
  });
60
+ markUserRespondedToBetaSignup(configDir);
34
61
  if (isCancel(shouldSignup) || !shouldSignup) return;
35
62
  const email = await text({
36
63
  message: "Enter your email address:",
@@ -54,7 +81,8 @@ async function promptBetaSignup(commandContext) {
54
81
  //#region src/hooks/postrun.ts
55
82
  const hook = async function(options) {
56
83
  if (options.Command) trackCommandCompleted(options.Command.id || options.Command.name || "unknown", true);
57
- if (options.Command && process.stdout.isTTY) await promptBetaSignup(options.Command.id || options.Command.name || "unknown");
84
+ const isInteractive = process.stdin.isTTY && process.stdout.isTTY && !process.env.CI && !process.env.NO_INTERACTIVE;
85
+ if (options.Command && isInteractive) await promptBetaSignup(options.Command.id || options.Command.name || "unknown", options.config.configDir);
58
86
  };
59
87
  var postrun_default = hook;
60
88
 
@@ -1,4 +1,4 @@
1
- import { r as trackCommandStarted } from "../analytics-CyANz2YH.js";
1
+ import { r as trackCommandStarted } from "../analytics-CgHTVQWO.js";
2
2
 
3
3
  //#region src/hooks/prerun.ts
4
4
  const hook = async function(options) {
@@ -57,7 +57,7 @@ var StoryGenerator = class extends BaseTemplateGenerator {
57
57
  }
58
58
  async generateBlockTemplate(destDir, options) {
59
59
  const scope = { block: {
60
- clsName: slugify(options.name, { lower: true }).split("-").map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
60
+ clsName: slugify(options.name, { lower: true }).split("-").filter(Boolean).map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
61
61
  framework: options.framework,
62
62
  name: options.name,
63
63
  slug: slugify(options.name, { lower: true })
@@ -69,7 +69,7 @@ var StoryGenerator = class extends BaseTemplateGenerator {
69
69
  }
70
70
  async generateThemeTemplate(destDir, options) {
71
71
  const themeScope = { theme: {
72
- clsName: slugify(options.name, { lower: true }).split("-").map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
72
+ clsName: slugify(options.name, { lower: true }).split("-").filter(Boolean).map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
73
73
  framework: options.framework,
74
74
  name: options.name,
75
75
  slug: slugify(options.name, { lower: true })
@@ -94,7 +94,7 @@ var JuoTemplateGenerator = class extends BaseTemplateGenerator {
94
94
  }
95
95
  async generateBlockTemplate(destDir, options) {
96
96
  const scope = { block: {
97
- clsName: slugify(options.name, { lower: true }).split("-").map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
97
+ clsName: slugify(options.name, { lower: true }).split("-").filter(Boolean).map((item) => `${item[0].toUpperCase()}${item.slice(1)}`).join(""),
98
98
  framework: options.framework,
99
99
  name: options.name,
100
100
  slug: slugify(options.name, { lower: true }),
@@ -104,6 +104,7 @@ var JuoTemplateGenerator = class extends BaseTemplateGenerator {
104
104
  options.logger?.("Adding block to theme");
105
105
  try {
106
106
  appendFileSync(path.join(destDir, "index.ts"), `export { ${scope.block.clsName}Block } from "./${scope.block.slug}";\n`);
107
+ this.regenerateRegisterFile(destDir);
107
108
  } catch (error) {
108
109
  options.logger?.("Error adding block to theme: " + error);
109
110
  throw error;
@@ -124,6 +125,36 @@ var JuoTemplateGenerator = class extends BaseTemplateGenerator {
124
125
  }
125
126
  } else options.logger?.(`Story generation skipped (options.story = ${options.story})`);
126
127
  }
128
+ /**
129
+ * Reads the current index.ts to extract all exported block names,
130
+ * then regenerates register.ts with a registerBlocks() function that
131
+ * registers each block via registerBlock() from @juo/blocks.
132
+ */
133
+ regenerateRegisterFile(blocksDir) {
134
+ const indexPath = path.join(blocksDir, "index.ts");
135
+ if (!existsSync(indexPath)) return;
136
+ const indexContent = readFileSync(indexPath, "utf8");
137
+ const exportRegex = /export\s*\{\s*(\w+)\s*\}\s*from\s*["']\.\/([^"']+)["']/g;
138
+ const exports = [];
139
+ let match;
140
+ while ((match = exportRegex.exec(indexContent)) !== null) exports.push({
141
+ name: match[1],
142
+ slug: match[2]
143
+ });
144
+ if (exports.length === 0) return;
145
+ const registerContent = [
146
+ `import { registerBlock } from "@juo/blocks";`,
147
+ exports.map(({ name, slug }) => `import { ${name} } from "./${slug}";`).join("\n"),
148
+ "",
149
+ `export function registerBlocks() {`,
150
+ exports.map(({ name }) => ` registerBlock(${name});`).join("\n"),
151
+ `}`,
152
+ "",
153
+ `export * from "./index";`,
154
+ ""
155
+ ].join("\n");
156
+ writeFileSync(path.join(blocksDir, "register.ts"), registerContent, "utf8");
157
+ }
127
158
  };
128
159
 
129
160
  //#endregion
@@ -33,6 +33,12 @@ declare class JuoTemplateGenerator extends BaseTemplateGenerator {
33
33
  appendStylesheet(destDir: string): void;
34
34
  generate(destDir: string, options: JuoBlockTemplateGeneratorOptions): Promise<void>;
35
35
  private generateBlockTemplate;
36
+ /**
37
+ * Reads the current index.ts to extract all exported block names,
38
+ * then regenerates register.ts with a registerBlocks() function that
39
+ * registers each block via registerBlock() from @juo/blocks.
40
+ */
41
+ private regenerateRegisterFile;
36
42
  }
37
43
  //#endregion
38
44
  //#region src/utils/packageGenerator.d.ts
package/dist/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as StoryGenerator, r as BaseTemplateGenerator, t as JuoTemplateGenerator } from "../juoTemplateGenerator-C0le5FdK.js";
2
- import { t as PackageGenerator } from "../packageGenerator-8E_-V5CL.js";
1
+ import { n as StoryGenerator, r as BaseTemplateGenerator, t as JuoTemplateGenerator } from "../juoTemplateGenerator-Ug40Yo7e.js";
2
+ import { t as PackageGenerator } from "../packageGenerator-Dno-ecHh.js";
3
3
 
4
4
  export { BaseTemplateGenerator, JuoTemplateGenerator, PackageGenerator, StoryGenerator };
@@ -63,7 +63,7 @@ var PackageGenerator = class {
63
63
  },
64
64
  engines: {
65
65
  node: ">=20.0.0",
66
- pnpm: ">=7.0.0"
66
+ ...options.packageManager === "pnpm" ? { pnpm: ">=7.0.0" } : {}
67
67
  },
68
68
  name: options.name,
69
69
  packageManager: `${options.packageManager}@${pmVersion}`,
@@ -137,5 +137,5 @@
137
137
  ]
138
138
  }
139
139
  },
140
- "version": "0.0.2-pre.1"
140
+ "version": "0.2.0"
141
141
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "juo",
3
3
  "description": "A CLI tool for the Juo platform",
4
- "version": "0.0.2-pre.1",
4
+ "version": "0.2.0",
5
5
  "author": "Juo (https://juo.io)",
6
6
  "bin": {
7
7
  "juo": "./bin/run.js"
@@ -74,6 +74,9 @@
74
74
  },
75
75
  "topicSeparator": " ",
76
76
  "topics": {
77
+ "blocks": {
78
+ "description": "Commands for blocks development"
79
+ },
77
80
  "publish": {
78
81
  "description": "Publish theme files"
79
82
  }
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from "vite";
2
+ import svgr from "vite-plugin-svgr";
3
+ {% if framework == "react" %}
4
+ import react from "@vitejs/plugin-react";
5
+ {% elsif framework == "preact" %}
6
+ import preact from "@preact/preset-vite";
7
+ {% endif %}
8
+
9
+ export default defineConfig({
10
+ define: {
11
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
12
+ },
13
+ plugins: [{% if framework == "react" %}react(), {% endif %}{% if framework == "preact" %}preact(), {% endif %}
14
+ svgr({
15
+ svgrOptions: {
16
+ icon: true,
17
+ },
18
+ }),
19
+ ],
20
+ preview: {
21
+ cors: true,
22
+ },
23
+ build: {
24
+ lib: {
25
+ entry: "src/blocks/register.ts",
26
+ formats: ["es"],
27
+ fileName: "index",
28
+ },
29
+ rollupOptions: {
30
+ external: ["@juo/blocks"],
31
+ },
32
+ },
33
+ });
@@ -8,6 +8,9 @@ import preact from "@preact/preset-vite";
8
8
  {% endif %}
9
9
 
10
10
  export default defineConfig({
11
+ define: {
12
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
13
+ },
11
14
  plugins: [tailwindcss(){% if framework == "react" %}, react(){% endif %}{% if framework == "preact" %}, preact(){% endif %},
12
15
  svgr({
13
16
  svgrOptions: {
@@ -15,19 +18,17 @@ export default defineConfig({
15
18
  },
16
19
  }),
17
20
  ],
21
+ preview: {
22
+ cors: true,
23
+ },
18
24
  build: {
19
25
  lib: {
20
- entry: "src/blocks/index.ts",
26
+ entry: "src/blocks/register.ts",
21
27
  formats: ["es"],
22
28
  fileName: "index",
23
29
  },
24
30
  rollupOptions: {
25
- external: [
26
- "@juo/blocks",
27
- "react",
28
- "react-dom",
29
- "preact",
30
- ],
31
+ external: ["@juo/blocks"],
31
32
  },
32
33
  },
33
34
  });