@velsefy/cli 0.1.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/LICENSE +21 -0
- package/README.md +130 -0
- package/THEME-DEVELOPMENT.md +270 -0
- package/dist/bin/velsefy.d.ts +2 -0
- package/dist/bin/velsefy.js +9 -0
- package/dist/bin/velsefy.js.map +1 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.js +21 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +18 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/theme.d.ts +2 -0
- package/dist/commands/theme.js +176 -0
- package/dist/commands/theme.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +17 -0
- package/dist/lib/api.js +129 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +8 -0
- package/dist/lib/config.js +28 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/credentials.d.ts +26 -0
- package/dist/lib/credentials.js +186 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/logger.d.ts +10 -0
- package/dist/lib/logger.js +41 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/paths.d.ts +6 -0
- package/dist/lib/paths.js +15 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/validate.d.ts +16 -0
- package/dist/lib/validate.js +86 -0
- package/dist/lib/validate.js.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { extractThemeInfoVersion, validateLiquid, validateJsonFile, validateSectionSchema, validateThemePath, } from "@velsefy/theme-validate";
|
|
4
|
+
const ALLOWED_DIRS = ["assets", "sections", "layout", "snippets", "config", "templates"];
|
|
5
|
+
function walkTree(root) {
|
|
6
|
+
const out = [];
|
|
7
|
+
const stack = [root];
|
|
8
|
+
while (stack.length > 0) {
|
|
9
|
+
const current = stack.pop();
|
|
10
|
+
const stat = fs.statSync(current);
|
|
11
|
+
if (stat.isDirectory()) {
|
|
12
|
+
for (const name of fs.readdirSync(current)) {
|
|
13
|
+
stack.push(path.join(current, name));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
out.push(current);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
/** Recolecta los archivos del tema dentro de las carpetas permitidas. */
|
|
23
|
+
export function collectThemeFiles(themeDir) {
|
|
24
|
+
const files = [];
|
|
25
|
+
for (const dir of ALLOWED_DIRS) {
|
|
26
|
+
const fullDir = path.join(themeDir, dir);
|
|
27
|
+
if (!fs.existsSync(fullDir))
|
|
28
|
+
continue;
|
|
29
|
+
for (const file of walkTree(fullDir)) {
|
|
30
|
+
files.push(file);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return files;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Valida un tema local: paths, balanceo de Liquid, JSON + estructura mínima,
|
|
37
|
+
* y extrae la versión del grupo `theme_info`.
|
|
38
|
+
*/
|
|
39
|
+
export function validate(themeDir) {
|
|
40
|
+
const issues = [];
|
|
41
|
+
if (!fs.existsSync(themeDir)) {
|
|
42
|
+
return {
|
|
43
|
+
valid: false,
|
|
44
|
+
issues: [{ file: "(raíz)", message: `El directorio del tema no existe: ${themeDir}` }],
|
|
45
|
+
themeVersion: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const files = collectThemeFiles(themeDir);
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
const relative = path.relative(themeDir, file);
|
|
51
|
+
const normalized = relative.split(path.sep).join("/");
|
|
52
|
+
const ext = path.extname(file).toLowerCase();
|
|
53
|
+
if (!validateThemePath(normalized)) {
|
|
54
|
+
issues.push({ file: relative, message: `Path no permitido: ${normalized}` });
|
|
55
|
+
}
|
|
56
|
+
if (ext === ".liquid") {
|
|
57
|
+
const source = fs.readFileSync(file, "utf8");
|
|
58
|
+
for (const message of validateLiquid(source)) {
|
|
59
|
+
issues.push({ file: relative, message });
|
|
60
|
+
}
|
|
61
|
+
// Validación del bloque {% schema %}: tipos de settings permitidos + id.
|
|
62
|
+
for (const issue of validateSectionSchema(source)) {
|
|
63
|
+
issues.push({ file: relative, message: `${issue.path}: ${issue.message}` });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (ext === ".json") {
|
|
67
|
+
const source = fs.readFileSync(file, "utf8");
|
|
68
|
+
for (const message of validateJsonFile(source, normalized)) {
|
|
69
|
+
issues.push({ file: relative, message });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let themeVersion = null;
|
|
74
|
+
const schemaPath = path.join(themeDir, "config", "settings_schema.json");
|
|
75
|
+
if (fs.existsSync(schemaPath)) {
|
|
76
|
+
try {
|
|
77
|
+
const schema = JSON.parse(fs.readFileSync(schemaPath, "utf8"));
|
|
78
|
+
themeVersion = extractThemeInfoVersion(schema);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// el JSON inválido ya se reporta por validateJsonFile
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { valid: issues.length === 0, issues, themeVersion };
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/lib/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MA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: string;
|
|
5
|
+
name: string;
|
|
6
|
+
status: string;
|
|
7
|
+
updatedAt?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ThemeAsset {
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
updatedAt?: string;
|
|
13
|
+
/** El API (api-v1) devuelve `updated_at` (snake_case, desde la RPC get_theme_assets). */
|
|
14
|
+
updated_at?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ReleaseAsset {
|
|
17
|
+
path: string;
|
|
18
|
+
content: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ConflictItem {
|
|
21
|
+
path: string;
|
|
22
|
+
serverUpdatedAt: string;
|
|
23
|
+
localUpdatedAt?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ConflictResult {
|
|
26
|
+
status: 409;
|
|
27
|
+
message: string;
|
|
28
|
+
conflicts: ConflictItem[];
|
|
29
|
+
}
|
|
30
|
+
export type PushResult = {
|
|
31
|
+
status: "ok";
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
} | {
|
|
34
|
+
status: "conflict";
|
|
35
|
+
conflict: ConflictResult;
|
|
36
|
+
};
|
|
37
|
+
export interface ReleaseThemeResult {
|
|
38
|
+
id?: string;
|
|
39
|
+
version?: string;
|
|
40
|
+
sku?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@velsefy/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI cross-platform de VELSEFY para gestionar temas (eCommerce + POS multi-tenant).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"velsefy": "dist/bin/velsefy.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"THEME-DEVELOPMENT.md"
|
|
14
|
+
],
|
|
15
|
+
"workspaces": [
|
|
16
|
+
"packages/*"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prebuild": "npm run build --workspace @velsefy/theme-validate",
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"pretypecheck": "npm run build --workspace @velsefy/theme-validate",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "eslint .",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/fivepulsespa-spec/velsefy-cli.git"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/fivepulsespa-spec/velsefy-cli#readme",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/fivepulsespa-spec/velsefy-cli/issues"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"velsefy",
|
|
39
|
+
"ecommerce",
|
|
40
|
+
"pos",
|
|
41
|
+
"themes",
|
|
42
|
+
"liquid",
|
|
43
|
+
"cli",
|
|
44
|
+
"shopify",
|
|
45
|
+
"multi-tenant"
|
|
46
|
+
],
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@velsefy/theme-validate": "0.0.1",
|
|
53
|
+
"commander": "^13.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.0.0",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
59
|
+
"eslint": "^9.0.0",
|
|
60
|
+
"typescript": "^5.6.0"
|
|
61
|
+
}
|
|
62
|
+
}
|