juo 0.1.0 → 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 +1 -1
- package/dist/commands/create.d.ts +4 -4
- package/dist/commands/create.js +2 -2
- package/dist/commands/generate.d.ts +5 -5
- package/dist/commands/generate.js +2 -2
- package/dist/commands/publish/index.d.ts +4 -2
- package/dist/commands/publish/index.js +19 -0
- package/dist/{generate-vpUPJZRH.js → generate-D9WUAwYz.js} +1 -1
- package/dist/{juoTemplateGenerator-MZ8llr7w.js → juoTemplateGenerator-Ug40Yo7e.js} +31 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +4 -1
- package/templates/configFiles/vite.config.ts.liquid +33 -0
- package/templates/tailwind/vite.config.ts.liquid +8 -7
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
|
-
import * as
|
|
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:
|
|
9
|
-
storybook:
|
|
10
|
-
verbose:
|
|
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;
|
package/dist/commands/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-
|
|
1
|
+
import { r as BaseTemplateGenerator } from "../juoTemplateGenerator-Ug40Yo7e.js";
|
|
2
2
|
import { t as PackageGenerator } from "../packageGenerator-Dno-ecHh.js";
|
|
3
|
-
import { t as Generate } from "../generate-
|
|
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";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
|
-
import * as
|
|
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:
|
|
10
|
-
tailwind:
|
|
11
|
-
type:
|
|
12
|
-
verbose:
|
|
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,10 +1,11 @@
|
|
|
1
1
|
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
-
import * as
|
|
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:
|
|
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-
|
|
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";
|
|
@@ -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
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -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-
|
|
1
|
+
import { n as StoryGenerator, r as BaseTemplateGenerator, t as JuoTemplateGenerator } from "../juoTemplateGenerator-Ug40Yo7e.js";
|
|
2
2
|
import { t as PackageGenerator } from "../packageGenerator-Dno-ecHh.js";
|
|
3
3
|
|
|
4
4
|
export { BaseTemplateGenerator, JuoTemplateGenerator, PackageGenerator, StoryGenerator };
|
package/oclif.manifest.json
CHANGED
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.
|
|
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/
|
|
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
|
});
|