juo 0.2.0 → 0.2.1
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 +27 -1
- package/dist/base-command-BQVnm_gK.d.ts +28 -0
- package/dist/base-command-CqPEFZ4E.js +115 -0
- package/dist/commands/blocks/dev.d.ts +16 -0
- package/dist/commands/blocks/dev.js +91 -0
- package/dist/commands/create.d.ts +4 -4
- package/dist/commands/create.js +3 -3
- package/dist/commands/generate.d.ts +5 -5
- package/dist/commands/generate.js +2 -2
- package/dist/commands/publish/index.d.ts +3 -28
- package/dist/commands/publish/index.js +2 -111
- package/dist/{generate-D9WUAwYz.js → generate-CUst3S4-.js} +1 -1
- package/dist/hooks/postrun.js +1 -1
- package/dist/hooks/prerun.js +1 -1
- package/dist/lib/index.js +2 -2
- package/oclif.manifest.json +43 -1
- package/package.json +1 -1
- /package/dist/{analytics-CgHTVQWO.js → analytics-BMClHCkY.js} +0 -0
- /package/dist/{juoTemplateGenerator-Ug40Yo7e.js → juoTemplateGenerator-Bsxy3cfd.js} +0 -0
- /package/dist/{packageGenerator-Dno-ecHh.js → packageGenerator-BiEzLxCa.js} +0 -0
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.2.
|
|
23
|
+
juo/0.2.1 linux-x64 node-v22.21.0
|
|
24
24
|
$ juo --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ juo COMMAND
|
|
@@ -31,11 +31,37 @@ USAGE
|
|
|
31
31
|
# Commands
|
|
32
32
|
|
|
33
33
|
<!-- commands -->
|
|
34
|
+
* [`juo blocks dev`](#juo-blocks-dev)
|
|
34
35
|
* [`juo create`](#juo-create)
|
|
35
36
|
* [`juo generate`](#juo-generate)
|
|
36
37
|
* [`juo help [COMMAND]`](#juo-help-command)
|
|
37
38
|
* [`juo publish`](#juo-publish)
|
|
38
39
|
|
|
40
|
+
## `juo blocks dev`
|
|
41
|
+
|
|
42
|
+
Start local block dev server for use with the Juo editor
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
USAGE
|
|
46
|
+
$ juo blocks dev [--reconfigure] [-p <value>]
|
|
47
|
+
|
|
48
|
+
FLAGS
|
|
49
|
+
-p, --port=<value> [default: 5174] Port for the local block dev server
|
|
50
|
+
|
|
51
|
+
GLOBAL FLAGS
|
|
52
|
+
--reconfigure Reconfigure settings
|
|
53
|
+
|
|
54
|
+
DESCRIPTION
|
|
55
|
+
Start local block dev server for use with the Juo editor
|
|
56
|
+
|
|
57
|
+
EXAMPLES
|
|
58
|
+
$ juo blocks dev
|
|
59
|
+
Start dev server on default port (5174).
|
|
60
|
+
|
|
61
|
+
$ juo blocks dev --port 3000
|
|
62
|
+
Start dev server on port 3000.
|
|
63
|
+
```
|
|
64
|
+
|
|
39
65
|
## `juo create`
|
|
40
66
|
|
|
41
67
|
Generate a new Juo project
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
+
|
|
3
|
+
//#region src/base-command.d.ts
|
|
4
|
+
interface BaseConfig {
|
|
5
|
+
JUO_API_KEY: string;
|
|
6
|
+
JUO_API_URL: string;
|
|
7
|
+
JUO_TENANT_ID?: string;
|
|
8
|
+
}
|
|
9
|
+
type Flags$1<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
|
|
10
|
+
type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
11
|
+
declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
12
|
+
static baseFlags: {
|
|
13
|
+
reconfigure: Interfaces.BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
protected args: Args<T>;
|
|
16
|
+
protected flags: Flags$1<T>;
|
|
17
|
+
protected get configFileName(): string;
|
|
18
|
+
protected get configFilePath(): string;
|
|
19
|
+
protected configExists(): boolean;
|
|
20
|
+
protected ensureConfig(reconfigure?: boolean): Promise<BaseConfig>;
|
|
21
|
+
protected ensureTenantId(): Promise<string>;
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
protected loadConfig(): Partial<BaseConfig>;
|
|
24
|
+
protected saveConfig(config: Partial<BaseConfig>): void;
|
|
25
|
+
protected validateConfig(config: Partial<BaseConfig>): config is BaseConfig;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { BaseCommand as t };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
|
|
6
|
+
//#region src/base-command.ts
|
|
7
|
+
var BaseCommand = class extends Command {
|
|
8
|
+
static baseFlags = { reconfigure: Flags.boolean({
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Reconfigure settings",
|
|
11
|
+
helpGroup: "GLOBAL"
|
|
12
|
+
}) };
|
|
13
|
+
args;
|
|
14
|
+
flags;
|
|
15
|
+
get configFileName() {
|
|
16
|
+
return "config.json";
|
|
17
|
+
}
|
|
18
|
+
get configFilePath() {
|
|
19
|
+
return path.join(this.config.configDir, this.configFileName);
|
|
20
|
+
}
|
|
21
|
+
configExists() {
|
|
22
|
+
return fs.existsSync(this.configFilePath);
|
|
23
|
+
}
|
|
24
|
+
async ensureConfig(reconfigure = false) {
|
|
25
|
+
let config = {};
|
|
26
|
+
if (this.configExists()) try {
|
|
27
|
+
config = this.loadConfig();
|
|
28
|
+
if (this.validateConfig(config) && !reconfigure) {
|
|
29
|
+
this.log(`Found configuration at ${this.configFilePath}`);
|
|
30
|
+
return config;
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
this.log(`Warning: Could not parse existing config at ${this.configFilePath}`);
|
|
34
|
+
}
|
|
35
|
+
if (reconfigure && this.validateConfig(config)) this.log("Reconfiguring settings...");
|
|
36
|
+
else this.log("Configuration incomplete. Setting up...");
|
|
37
|
+
const questions = [];
|
|
38
|
+
if (!config.JUO_API_URL || reconfigure) questions.push({
|
|
39
|
+
default: "https://api.juo.io",
|
|
40
|
+
message: "Enter the Juo API URL:",
|
|
41
|
+
name: "JUO_API_URL",
|
|
42
|
+
type: "input",
|
|
43
|
+
validate(input) {
|
|
44
|
+
if (!input.trim()) return "Juo API URL is required";
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
if (!config.JUO_API_KEY || reconfigure) questions.push({
|
|
49
|
+
message: "Enter your Juo API key:",
|
|
50
|
+
name: "JUO_API_KEY",
|
|
51
|
+
type: "password",
|
|
52
|
+
validate(input) {
|
|
53
|
+
if (!input.trim()) return "Juo API key is required";
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (questions.length === 0) return config;
|
|
58
|
+
const response = await inquirer.prompt(questions);
|
|
59
|
+
if (response.JUO_API_URL) config.JUO_API_URL = response.JUO_API_URL.trim();
|
|
60
|
+
if (response.JUO_API_KEY) config.JUO_API_KEY = response.JUO_API_KEY.trim();
|
|
61
|
+
this.saveConfig(config);
|
|
62
|
+
this.log(`Saved configuration to ${this.configFilePath}`);
|
|
63
|
+
if (this.validateConfig(config)) return config;
|
|
64
|
+
throw new Error("Failed to create valid configuration");
|
|
65
|
+
}
|
|
66
|
+
async ensureTenantId() {
|
|
67
|
+
let config = {};
|
|
68
|
+
if (this.configExists()) try {
|
|
69
|
+
config = this.loadConfig();
|
|
70
|
+
if (config.JUO_TENANT_ID?.trim()) return config.JUO_TENANT_ID.trim();
|
|
71
|
+
} catch {}
|
|
72
|
+
const tenantId = (await inquirer.prompt([{
|
|
73
|
+
message: "Enter your tenant ID (shop identifier):",
|
|
74
|
+
name: "JUO_TENANT_ID",
|
|
75
|
+
type: "input",
|
|
76
|
+
validate(input) {
|
|
77
|
+
if (!input.trim()) return "Tenant ID is required";
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}])).JUO_TENANT_ID.trim().replace(/\.myshopify\.com$/, "");
|
|
81
|
+
config.JUO_TENANT_ID = tenantId;
|
|
82
|
+
this.saveConfig(config);
|
|
83
|
+
return tenantId;
|
|
84
|
+
}
|
|
85
|
+
async init() {
|
|
86
|
+
await super.init();
|
|
87
|
+
const { args, flags } = await this.parse({
|
|
88
|
+
args: this.ctor.args,
|
|
89
|
+
baseFlags: super.ctor.baseFlags,
|
|
90
|
+
flags: this.ctor.flags,
|
|
91
|
+
strict: this.ctor.strict
|
|
92
|
+
});
|
|
93
|
+
this.flags = flags;
|
|
94
|
+
this.args = args;
|
|
95
|
+
}
|
|
96
|
+
loadConfig() {
|
|
97
|
+
if (!this.configExists()) throw new Error(`Configuration file not found at ${this.configFilePath}`);
|
|
98
|
+
try {
|
|
99
|
+
const configContent = fs.readFileSync(this.configFilePath, "utf8");
|
|
100
|
+
return JSON.parse(configContent);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw new Error(`Failed to parse configuration file at ${this.configFilePath}: ${error}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
saveConfig(config) {
|
|
106
|
+
fs.mkdirSync(this.config.configDir, { recursive: true });
|
|
107
|
+
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2), { encoding: "utf8" });
|
|
108
|
+
}
|
|
109
|
+
validateConfig(config) {
|
|
110
|
+
return Boolean(config.JUO_API_KEY && config.JUO_API_KEY.trim().length > 0 && config.JUO_API_URL && config.JUO_API_URL.trim().length > 0);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { BaseCommand as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { t as BaseCommand } from "../../base-command-BQVnm_gK.js";
|
|
2
|
+
import * as _oclif_core_interfaces10 from "@oclif/core/interfaces";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/blocks/dev.d.ts
|
|
5
|
+
declare class Dev extends BaseCommand<typeof Dev> {
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
port: _oclif_core_interfaces10.OptionFlag<number, _oclif_core_interfaces10.CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
private resolvePackageJsonPath;
|
|
13
|
+
private waitForFile;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Dev as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { t as BaseCommand } from "../../base-command-CqPEFZ4E.js";
|
|
2
|
+
import { Flags } from "@oclif/core";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/blocks/dev.ts
|
|
8
|
+
var Dev = class Dev extends BaseCommand {
|
|
9
|
+
static description = "Start local block dev server for use with the Juo editor";
|
|
10
|
+
static examples = [`<%= config.bin %> <%= command.id %>
|
|
11
|
+
Start dev server on default port (5174).
|
|
12
|
+
`, `<%= config.bin %> <%= command.id %> --port 3000
|
|
13
|
+
Start dev server on port 3000.
|
|
14
|
+
`];
|
|
15
|
+
static flags = { port: Flags.integer({
|
|
16
|
+
char: "p",
|
|
17
|
+
default: 5174,
|
|
18
|
+
description: "Port for the local block dev server"
|
|
19
|
+
}) };
|
|
20
|
+
async run() {
|
|
21
|
+
const { flags } = await this.parse(Dev);
|
|
22
|
+
const { port } = flags;
|
|
23
|
+
const rootDir = this.resolvePackageJsonPath();
|
|
24
|
+
const tenantId = await this.ensureTenantId();
|
|
25
|
+
const devBlocksUrl = `http://localhost:${port}/index.js`;
|
|
26
|
+
const editorUrl = `https://admin.juo.io/store/${encodeURIComponent(tenantId)}/editor?dev-blocks-url=${encodeURIComponent(devBlocksUrl)}`;
|
|
27
|
+
this.log(`\nStarting Juo Blocks dev server...`);
|
|
28
|
+
this.log(`\n Open the editor to preview your blocks:`);
|
|
29
|
+
this.log(` ${editorUrl}`);
|
|
30
|
+
this.log(`\n Dev server running on http://localhost:${port}\n`);
|
|
31
|
+
const viteBuild = spawn("npx", [
|
|
32
|
+
"vite",
|
|
33
|
+
"build",
|
|
34
|
+
"--watch"
|
|
35
|
+
], {
|
|
36
|
+
cwd: rootDir,
|
|
37
|
+
shell: true,
|
|
38
|
+
stdio: "inherit"
|
|
39
|
+
});
|
|
40
|
+
viteBuild.on("error", (err) => {
|
|
41
|
+
this.error(`Failed to start vite build: ${err.message}`);
|
|
42
|
+
});
|
|
43
|
+
const distFile = path.join(rootDir, "dist", "index.js");
|
|
44
|
+
await this.waitForFile(distFile);
|
|
45
|
+
const vitePreview = spawn("npx", [
|
|
46
|
+
"vite",
|
|
47
|
+
"preview",
|
|
48
|
+
"--port",
|
|
49
|
+
String(port)
|
|
50
|
+
], {
|
|
51
|
+
cwd: rootDir,
|
|
52
|
+
shell: true,
|
|
53
|
+
stdio: "inherit"
|
|
54
|
+
});
|
|
55
|
+
vitePreview.on("error", (err) => {
|
|
56
|
+
this.error(`Failed to start vite preview: ${err.message}`);
|
|
57
|
+
});
|
|
58
|
+
this.log(`\nDev server ready. Press Ctrl+C to stop.\n`);
|
|
59
|
+
const cleanup = () => {
|
|
60
|
+
viteBuild.kill();
|
|
61
|
+
vitePreview.kill();
|
|
62
|
+
process.exit(0);
|
|
63
|
+
};
|
|
64
|
+
process.on("SIGINT", cleanup);
|
|
65
|
+
process.on("SIGTERM", cleanup);
|
|
66
|
+
await new Promise(() => {});
|
|
67
|
+
}
|
|
68
|
+
resolvePackageJsonPath() {
|
|
69
|
+
let currentPath = path.resolve("./");
|
|
70
|
+
while (!existsSync(path.join(currentPath, "package.json"))) {
|
|
71
|
+
const parentDir = path.dirname(currentPath);
|
|
72
|
+
if (parentDir === currentPath) throw new Error("Could not find 'package.json' in the project");
|
|
73
|
+
currentPath = parentDir;
|
|
74
|
+
}
|
|
75
|
+
return currentPath;
|
|
76
|
+
}
|
|
77
|
+
async waitForFile(filePath, timeout = 3e4) {
|
|
78
|
+
const interval = 200;
|
|
79
|
+
let waited = 0;
|
|
80
|
+
while (!existsSync(filePath) && waited < timeout) {
|
|
81
|
+
await new Promise((resolve) => {
|
|
82
|
+
setTimeout(resolve, interval);
|
|
83
|
+
});
|
|
84
|
+
waited += interval;
|
|
85
|
+
}
|
|
86
|
+
if (!existsSync(filePath)) this.error(`Timed out waiting for ${filePath}`);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { Dev as default };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _oclif_core_interfaces5 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:
|
|
9
|
-
storybook:
|
|
10
|
-
verbose:
|
|
8
|
+
quickstart: _oclif_core_interfaces5.BooleanFlag<boolean>;
|
|
9
|
+
storybook: _oclif_core_interfaces5.BooleanFlag<boolean>;
|
|
10
|
+
verbose: _oclif_core_interfaces5.BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
private getProjectConfig;
|
package/dist/commands/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-
|
|
2
|
-
import { t as PackageGenerator } from "../packageGenerator-
|
|
3
|
-
import { t as Generate } from "../generate-
|
|
1
|
+
import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-Bsxy3cfd.js";
|
|
2
|
+
import { t as PackageGenerator } from "../packageGenerator-BiEzLxCa.js";
|
|
3
|
+
import { t as Generate } from "../generate-CUst3S4-.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";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _oclif_core_interfaces0 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:
|
|
10
|
-
tailwind:
|
|
11
|
-
type:
|
|
12
|
-
verbose:
|
|
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>;
|
|
13
13
|
};
|
|
14
14
|
static id: string;
|
|
15
15
|
run(): Promise<void>;
|
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
1
|
+
import { t as BaseCommand } from "../../base-command-BQVnm_gK.js";
|
|
2
|
+
import * as _oclif_core_interfaces8 from "@oclif/core/interfaces";
|
|
3
3
|
|
|
4
|
-
//#region src/base-command.d.ts
|
|
5
|
-
interface BaseConfig {
|
|
6
|
-
JUO_API_KEY: string;
|
|
7
|
-
JUO_API_URL: string;
|
|
8
|
-
JUO_TENANT_ID?: string;
|
|
9
|
-
}
|
|
10
|
-
type Flags$1<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
|
|
11
|
-
type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
12
|
-
declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
13
|
-
static baseFlags: {
|
|
14
|
-
reconfigure: Interfaces.BooleanFlag<boolean>;
|
|
15
|
-
};
|
|
16
|
-
protected args: Args<T>;
|
|
17
|
-
protected flags: Flags$1<T>;
|
|
18
|
-
protected get configFileName(): string;
|
|
19
|
-
protected get configFilePath(): string;
|
|
20
|
-
protected configExists(): boolean;
|
|
21
|
-
protected ensureConfig(reconfigure?: boolean): Promise<BaseConfig>;
|
|
22
|
-
protected ensureTenantId(): Promise<string>;
|
|
23
|
-
init(): Promise<void>;
|
|
24
|
-
protected loadConfig(): Partial<BaseConfig>;
|
|
25
|
-
protected saveConfig(config: Partial<BaseConfig>): void;
|
|
26
|
-
protected validateConfig(config: Partial<BaseConfig>): config is BaseConfig;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
4
|
//#region src/commands/publish/index.d.ts
|
|
30
5
|
declare class Publish extends BaseCommand<typeof Publish> {
|
|
31
6
|
static args: {};
|
|
32
7
|
static description: string;
|
|
33
8
|
static examples: string[];
|
|
34
9
|
static flags: {
|
|
35
|
-
theme:
|
|
10
|
+
theme: _oclif_core_interfaces8.OptionFlag<string, _oclif_core_interfaces8.CustomOptions>;
|
|
36
11
|
};
|
|
37
12
|
getAllFiles(dirPath: string, basePath: string): string[];
|
|
38
13
|
run(): Promise<void>;
|
|
@@ -1,120 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as BaseCommand } from "../../base-command-CqPEFZ4E.js";
|
|
2
|
+
import { Flags } from "@oclif/core";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
5
6
|
import mime from "mime";
|
|
6
7
|
import asyncPool from "tiny-async-pool";
|
|
7
|
-
import inquirer from "inquirer";
|
|
8
8
|
|
|
9
|
-
//#region src/base-command.ts
|
|
10
|
-
var BaseCommand = class extends Command {
|
|
11
|
-
static baseFlags = { reconfigure: Flags.boolean({
|
|
12
|
-
default: false,
|
|
13
|
-
description: "Reconfigure settings",
|
|
14
|
-
helpGroup: "GLOBAL"
|
|
15
|
-
}) };
|
|
16
|
-
args;
|
|
17
|
-
flags;
|
|
18
|
-
get configFileName() {
|
|
19
|
-
return "config.json";
|
|
20
|
-
}
|
|
21
|
-
get configFilePath() {
|
|
22
|
-
return path.join(this.config.configDir, this.configFileName);
|
|
23
|
-
}
|
|
24
|
-
configExists() {
|
|
25
|
-
return fs.existsSync(this.configFilePath);
|
|
26
|
-
}
|
|
27
|
-
async ensureConfig(reconfigure = false) {
|
|
28
|
-
let config = {};
|
|
29
|
-
if (this.configExists()) try {
|
|
30
|
-
config = this.loadConfig();
|
|
31
|
-
if (this.validateConfig(config) && !reconfigure) {
|
|
32
|
-
this.log(`Found configuration at ${this.configFilePath}`);
|
|
33
|
-
return config;
|
|
34
|
-
}
|
|
35
|
-
} catch {
|
|
36
|
-
this.log(`Warning: Could not parse existing config at ${this.configFilePath}`);
|
|
37
|
-
}
|
|
38
|
-
if (reconfigure && this.validateConfig(config)) this.log("Reconfiguring settings...");
|
|
39
|
-
else this.log("Configuration incomplete. Setting up...");
|
|
40
|
-
const questions = [];
|
|
41
|
-
if (!config.JUO_API_URL || reconfigure) questions.push({
|
|
42
|
-
default: "https://api.juo.io",
|
|
43
|
-
message: "Enter the Juo API URL:",
|
|
44
|
-
name: "JUO_API_URL",
|
|
45
|
-
type: "input",
|
|
46
|
-
validate(input) {
|
|
47
|
-
if (!input.trim()) return "Juo API URL is required";
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (!config.JUO_API_KEY || reconfigure) questions.push({
|
|
52
|
-
message: "Enter your Juo API key:",
|
|
53
|
-
name: "JUO_API_KEY",
|
|
54
|
-
type: "password",
|
|
55
|
-
validate(input) {
|
|
56
|
-
if (!input.trim()) return "Juo API key is required";
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
if (questions.length === 0) return config;
|
|
61
|
-
const response = await inquirer.prompt(questions);
|
|
62
|
-
if (response.JUO_API_URL) config.JUO_API_URL = response.JUO_API_URL.trim();
|
|
63
|
-
if (response.JUO_API_KEY) config.JUO_API_KEY = response.JUO_API_KEY.trim();
|
|
64
|
-
this.saveConfig(config);
|
|
65
|
-
this.log(`Saved configuration to ${this.configFilePath}`);
|
|
66
|
-
if (this.validateConfig(config)) return config;
|
|
67
|
-
throw new Error("Failed to create valid configuration");
|
|
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
|
-
}
|
|
88
|
-
async init() {
|
|
89
|
-
await super.init();
|
|
90
|
-
const { args, flags } = await this.parse({
|
|
91
|
-
args: this.ctor.args,
|
|
92
|
-
baseFlags: super.ctor.baseFlags,
|
|
93
|
-
flags: this.ctor.flags,
|
|
94
|
-
strict: this.ctor.strict
|
|
95
|
-
});
|
|
96
|
-
this.flags = flags;
|
|
97
|
-
this.args = args;
|
|
98
|
-
}
|
|
99
|
-
loadConfig() {
|
|
100
|
-
if (!this.configExists()) throw new Error(`Configuration file not found at ${this.configFilePath}`);
|
|
101
|
-
try {
|
|
102
|
-
const configContent = fs.readFileSync(this.configFilePath, "utf8");
|
|
103
|
-
return JSON.parse(configContent);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
throw new Error(`Failed to parse configuration file at ${this.configFilePath}: ${error}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
saveConfig(config) {
|
|
109
|
-
fs.mkdirSync(this.config.configDir, { recursive: true });
|
|
110
|
-
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2), { encoding: "utf8" });
|
|
111
|
-
}
|
|
112
|
-
validateConfig(config) {
|
|
113
|
-
return Boolean(config.JUO_API_KEY && config.JUO_API_KEY.trim().length > 0 && config.JUO_API_URL && config.JUO_API_URL.trim().length > 0);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
9
|
//#region src/commands/publish/index.ts
|
|
119
10
|
var Publish = class extends BaseCommand {
|
|
120
11
|
static args = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as JuoTemplateGenerator } from "./juoTemplateGenerator-
|
|
1
|
+
import { t as JuoTemplateGenerator } from "./juoTemplateGenerator-Bsxy3cfd.js";
|
|
2
2
|
import { Command, Flags } from "@oclif/core";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
package/dist/hooks/postrun.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-BMClHCkY.js";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { confirm, isCancel, text } from "@clack/prompts";
|
package/dist/hooks/prerun.js
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as StoryGenerator, r as BaseTemplateGenerator, t as JuoTemplateGenerator } from "../juoTemplateGenerator-
|
|
2
|
-
import { t as PackageGenerator } from "../packageGenerator-
|
|
1
|
+
import { n as StoryGenerator, r as BaseTemplateGenerator, t as JuoTemplateGenerator } from "../juoTemplateGenerator-Bsxy3cfd.js";
|
|
2
|
+
import { t as PackageGenerator } from "../packageGenerator-BiEzLxCa.js";
|
|
3
3
|
|
|
4
4
|
export { BaseTemplateGenerator, JuoTemplateGenerator, PackageGenerator, StoryGenerator };
|
package/oclif.manifest.json
CHANGED
|
@@ -93,6 +93,48 @@
|
|
|
93
93
|
"generate.js"
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
|
+
"blocks:dev": {
|
|
97
|
+
"aliases": [],
|
|
98
|
+
"args": {},
|
|
99
|
+
"description": "Start local block dev server for use with the Juo editor",
|
|
100
|
+
"examples": [
|
|
101
|
+
"<%= config.bin %> <%= command.id %>\nStart dev server on default port (5174).\n",
|
|
102
|
+
"<%= config.bin %> <%= command.id %> --port 3000\nStart dev server on port 3000.\n"
|
|
103
|
+
],
|
|
104
|
+
"flags": {
|
|
105
|
+
"reconfigure": {
|
|
106
|
+
"description": "Reconfigure settings",
|
|
107
|
+
"helpGroup": "GLOBAL",
|
|
108
|
+
"name": "reconfigure",
|
|
109
|
+
"allowNo": false,
|
|
110
|
+
"type": "boolean"
|
|
111
|
+
},
|
|
112
|
+
"port": {
|
|
113
|
+
"char": "p",
|
|
114
|
+
"description": "Port for the local block dev server",
|
|
115
|
+
"name": "port",
|
|
116
|
+
"default": 5174,
|
|
117
|
+
"hasDynamicHelp": false,
|
|
118
|
+
"multiple": false,
|
|
119
|
+
"type": "option"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"hasDynamicHelp": false,
|
|
123
|
+
"hiddenAliases": [],
|
|
124
|
+
"id": "blocks:dev",
|
|
125
|
+
"pluginAlias": "juo",
|
|
126
|
+
"pluginName": "juo",
|
|
127
|
+
"pluginType": "core",
|
|
128
|
+
"strict": true,
|
|
129
|
+
"enableJsonFlag": false,
|
|
130
|
+
"isESM": true,
|
|
131
|
+
"relativePath": [
|
|
132
|
+
"dist",
|
|
133
|
+
"commands",
|
|
134
|
+
"blocks",
|
|
135
|
+
"dev.js"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
96
138
|
"publish": {
|
|
97
139
|
"aliases": [],
|
|
98
140
|
"args": {},
|
|
@@ -137,5 +179,5 @@
|
|
|
137
179
|
]
|
|
138
180
|
}
|
|
139
181
|
},
|
|
140
|
-
"version": "0.2.
|
|
182
|
+
"version": "0.2.1"
|
|
141
183
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|