tiendu 0.3.0 → 0.4.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
@@ -126,20 +126,50 @@ tiendu dev
126
126
  Zips and uploads files to the active preview, replacing its content entirely.
127
127
 
128
128
  - **Buildless themes:** uploads from the current directory.
129
- - **Built themes:** uploads from `dist/`.
129
+ - **Built themes:** runs `tiendu build` first, then uploads from `dist/`.
130
130
 
131
131
  ```bash
132
132
  tiendu push
133
+ tiendu push --skip-build
133
134
  ```
134
135
 
136
+ Use `--skip-build` to upload the existing `dist/` output without rebuilding.
137
+
135
138
  ---
136
139
 
137
140
  ### `tiendu publish`
138
141
 
139
142
  Publishes the active preview to the live storefront. Visitors will see the new theme immediately. All previews for the store are removed after publishing.
140
143
 
144
+ - **Buildless themes:** publishes the active preview as-is.
145
+ - **Built themes:** builds the theme, uploads the latest `dist/` output to the preview, then publishes it.
146
+
141
147
  ```bash
142
148
  tiendu publish
149
+ tiendu publish --skip-build
150
+ ```
151
+
152
+ Use `--skip-build` to publish after uploading the existing `dist/` output without rebuilding.
153
+
154
+ ---
155
+
156
+ ### `tiendu check-updates`
157
+
158
+ Checks npm for a newer `tiendu` version on demand.
159
+
160
+ ```bash
161
+ tiendu check-updates
162
+ ```
163
+
164
+ ---
165
+
166
+ ### `tiendu --version` / `tiendu -v`
167
+
168
+ Prints the current CLI version.
169
+
170
+ ```bash
171
+ tiendu --version
172
+ tiendu -v
143
173
  ```
144
174
 
145
175
  ---
package/bin/tiendu.js CHANGED
@@ -13,7 +13,11 @@ import {
13
13
  previewDelete,
14
14
  previewOpen,
15
15
  } from "../lib/preview.mjs";
16
- import { checkForUpdates } from "../lib/update-check.mjs";
16
+ import {
17
+ checkForUpdates,
18
+ checkForUpdatesNow,
19
+ getCurrentVersion,
20
+ } from "../lib/update-check.mjs";
17
21
 
18
22
  const HELP = `
19
23
  tiendu — Tiendu theme development CLI
@@ -22,9 +26,10 @@ Usage:
22
26
  tiendu init [dir] Set up a theme project (optionally in a new directory)
23
27
  tiendu pull Download the live theme from your store
24
28
  tiendu build Build a theme (requires tiendu.config.json)
25
- tiendu push Upload local files to the active preview (full replace)
29
+ tiendu push [--skip-build] Upload local files to the active preview (full replace)
26
30
  tiendu dev Start dev mode: auto-sync changes to a live preview URL
27
- tiendu publish Publish the active preview to the live storefront
31
+ tiendu publish [--skip-build]
32
+ Publish the active preview to the live storefront
28
33
 
29
34
  tiendu preview Show the active preview details
30
35
  tiendu preview create Create a new remote preview
@@ -32,7 +37,11 @@ Usage:
32
37
  tiendu preview delete Delete the active preview
33
38
  tiendu preview open Open the active preview URL in your browser
34
39
 
40
+ tiendu check-updates Check npm for a newer CLI version
41
+ tiendu version Show the current CLI version
42
+
35
43
  tiendu help Show this help message
44
+ tiendu --version, -v Show the current CLI version
36
45
 
37
46
  Typical workflow:
38
47
  tiendu init my-store Set up a new project in ./my-store
@@ -47,9 +56,16 @@ const main = async () => {
47
56
  const args = process.argv.slice(2);
48
57
  const command = args[0];
49
58
  const subcommand = args[1];
59
+ const skipBuild = args.includes("--skip-build");
50
60
 
51
- // Check for updates at most once per day (non-blocking)
52
- await checkForUpdates();
61
+ if (
62
+ command === "version" ||
63
+ command === "--version" ||
64
+ command === "-v"
65
+ ) {
66
+ console.log(getCurrentVersion());
67
+ process.exit(0);
68
+ }
53
69
 
54
70
  if (
55
71
  !command ||
@@ -61,6 +77,14 @@ const main = async () => {
61
77
  process.exit(0);
62
78
  }
63
79
 
80
+ if (command === "check-updates") {
81
+ await checkForUpdatesNow();
82
+ return;
83
+ }
84
+
85
+ // Check for updates at most once per day (non-blocking)
86
+ await checkForUpdates();
87
+
64
88
  if (command === "init") {
65
89
  await init(args[1]); // optional directory name
66
90
  return;
@@ -78,7 +102,7 @@ const main = async () => {
78
102
  }
79
103
 
80
104
  if (command === "push") {
81
- await push();
105
+ await push({ skipBuild });
82
106
  return;
83
107
  }
84
108
 
@@ -88,7 +112,7 @@ const main = async () => {
88
112
  }
89
113
 
90
114
  if (command === "publish") {
91
- await publish();
115
+ await publish({ skipBuild });
92
116
  return;
93
117
  }
94
118
 
package/bin/tiendu.mjs CHANGED
@@ -11,6 +11,11 @@ import {
11
11
  previewDelete,
12
12
  previewOpen,
13
13
  } from "../lib/preview.mjs";
14
+ import {
15
+ checkForUpdates,
16
+ checkForUpdatesNow,
17
+ getCurrentVersion,
18
+ } from "../lib/update-check.mjs";
14
19
 
15
20
  const HELP = `
16
21
  tiendu — CLI para desarrollar temas de Tiendu
@@ -18,25 +23,40 @@ tiendu — CLI para desarrollar temas de Tiendu
18
23
  Uso:
19
24
  tiendu init Inicializar un tema en el directorio actual
20
25
  tiendu pull Descargar el tema live desde Tiendu
21
- tiendu push Subir archivos locales al preview activo (ZIP)
26
+ tiendu push [--skip-build] Subir archivos locales al preview activo (ZIP)
22
27
  tiendu dev Modo desarrollo: watch + sync automático
23
- tiendu publish Publicar el preview activo al storefront live
28
+ tiendu publish [--skip-build]
29
+ Publicar el preview activo al storefront live
24
30
 
25
31
  tiendu preview create Crear un preview remoto
26
32
  tiendu preview list Listar previews de la tienda
27
33
  tiendu preview delete Eliminar el preview activo
28
34
  tiendu preview open Abrir la URL del preview en el navegador
29
35
 
36
+ tiendu check-updates Buscar una nueva version del CLI
37
+ tiendu version Mostrar la version actual del CLI
38
+
30
39
  tiendu help Mostrar esta ayuda
31
40
 
32
- Opciones:
41
+ Opciones:
33
42
  --help, -h Mostrar esta ayuda
43
+ --version, -v Mostrar la version actual del CLI
34
44
  `;
35
45
 
36
46
  const main = async () => {
37
47
  const args = process.argv.slice(2);
38
48
  const command = args[0];
39
49
  const subcommand = args[1];
50
+ const skipBuild = args.includes("--skip-build");
51
+
52
+ if (
53
+ command === "version" ||
54
+ command === "--version" ||
55
+ command === "-v"
56
+ ) {
57
+ console.log(getCurrentVersion());
58
+ process.exit(0);
59
+ }
40
60
 
41
61
  if (
42
62
  !command ||
@@ -48,6 +68,13 @@ const main = async () => {
48
68
  process.exit(0);
49
69
  }
50
70
 
71
+ if (command === "check-updates") {
72
+ await checkForUpdatesNow();
73
+ return;
74
+ }
75
+
76
+ await checkForUpdates();
77
+
51
78
  if (command === "init") {
52
79
  await init();
53
80
  return;
@@ -59,7 +86,7 @@ const main = async () => {
59
86
  }
60
87
 
61
88
  if (command === "push") {
62
- await push();
89
+ await push({ skipBuild });
63
90
  return;
64
91
  }
65
92
 
@@ -69,7 +96,7 @@ const main = async () => {
69
96
  }
70
97
 
71
98
  if (command === "publish") {
72
- await publish();
99
+ await publish({ skipBuild });
73
100
  return;
74
101
  }
75
102
 
package/lib/publish.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as p from "@clack/prompts";
2
- import { loadConfigOrFail, writeConfig } from "./config.mjs";
2
+ import { loadConfigOrFail, writeConfig, isBuiltTheme } from "./config.mjs";
3
3
  import { publishPreview } from "./preview.mjs";
4
+ import { push } from "./push.mjs";
4
5
 
5
- export const publish = async () => {
6
+ export const publish = async ({ skipBuild = false } = {}) => {
6
7
  const { config, credentials } = await loadConfigOrFail();
7
8
 
8
9
  if (!config.previewKey) {
@@ -19,6 +20,15 @@ export const publish = async () => {
19
20
  process.exit(0);
20
21
  }
21
22
 
23
+ if (await isBuiltTheme()) {
24
+ p.log.info(
25
+ skipBuild
26
+ ? "Syncing existing dist/ output to the preview before publishing..."
27
+ : "Building and syncing the latest dist/ output before publishing...",
28
+ );
29
+ await push({ skipBuild });
30
+ }
31
+
22
32
  const spinner = p.spinner();
23
33
  spinner.start("Publishing preview...");
24
34
 
package/lib/push.mjs CHANGED
@@ -4,6 +4,7 @@ import * as p from "@clack/prompts";
4
4
  import { zipSync } from "fflate";
5
5
  import { loadConfigOrFail, isBuiltTheme, getDistDir } from "./config.mjs";
6
6
  import { uploadPreviewZip } from "./api.mjs";
7
+ import { build } from "./build.mjs";
7
8
 
8
9
  /** @param {number} bytes */
9
10
  const formatBytes = (bytes) => {
@@ -51,7 +52,7 @@ const createZipFromDirectory = async (rootDir) => {
51
52
  return Buffer.from(zipSync(entries, { level: 6 }));
52
53
  };
53
54
 
54
- export const push = async () => {
55
+ export const push = async ({ skipBuild = false } = {}) => {
55
56
  const { config, credentials } = await loadConfigOrFail();
56
57
 
57
58
  if (!config.previewKey) {
@@ -59,7 +60,16 @@ export const push = async () => {
59
60
  process.exit(1);
60
61
  }
61
62
 
62
- const rootDir = (await isBuiltTheme()) ? getDistDir() : process.cwd();
63
+ const builtTheme = await isBuiltTheme();
64
+
65
+ if (builtTheme && !skipBuild) {
66
+ const result = await build();
67
+ if (!result.ok) {
68
+ process.exit(1);
69
+ }
70
+ }
71
+
72
+ const rootDir = builtTheme ? getDistDir() : process.cwd();
63
73
  const spinner = p.spinner();
64
74
  spinner.start("Packing files...");
65
75
 
@@ -72,10 +72,7 @@ const isOlderVersion = (a, b) => {
72
72
  * Reads local package.json version.
73
73
  * @returns {string}
74
74
  */
75
- const getCurrentVersion = () => {
76
- // Resolved at import time via static path relative to this file
77
- return TIENDU_CLI_VERSION;
78
- };
75
+ export const getCurrentVersion = () => TIENDU_CLI_VERSION;
79
76
 
80
77
  // This constant is replaced at build time via package.json version
81
78
  // We read it dynamically to avoid hardcoding.
@@ -99,7 +96,7 @@ export const checkForUpdates = async () => {
99
96
 
100
97
  // If checked within the last 24h, use cached result
101
98
  if (state && now - state.lastChecked < ONE_DAY_MS) {
102
- const currentVersion = TIENDU_CLI_VERSION;
99
+ const currentVersion = getCurrentVersion();
103
100
  if (
104
101
  state.latestVersion &&
105
102
  isOlderVersion(currentVersion, state.latestVersion)
@@ -119,12 +116,40 @@ export const checkForUpdates = async () => {
119
116
  return;
120
117
  }
121
118
 
122
- const currentVersion = TIENDU_CLI_VERSION;
119
+ const currentVersion = getCurrentVersion();
123
120
  if (isOlderVersion(currentVersion, latestVersion)) {
124
121
  showUpdateNote(currentVersion, latestVersion);
125
122
  }
126
123
  };
127
124
 
125
+ export const checkForUpdatesNow = async () => {
126
+ const currentVersion = getCurrentVersion();
127
+ const latestVersion = await fetchLatestVersion();
128
+
129
+ await writeUpdateCheckState({
130
+ lastChecked: Date.now(),
131
+ latestVersion,
132
+ });
133
+
134
+ if (!latestVersion) {
135
+ p.log.error("Could not check for updates right now.");
136
+ return { ok: false };
137
+ }
138
+
139
+ if (isOlderVersion(currentVersion, latestVersion)) {
140
+ showUpdateNote(currentVersion, latestVersion);
141
+ } else {
142
+ p.log.success(`You're on the latest version (${currentVersion}).`);
143
+ }
144
+
145
+ return {
146
+ ok: true,
147
+ currentVersion,
148
+ latestVersion,
149
+ updateAvailable: isOlderVersion(currentVersion, latestVersion),
150
+ };
151
+ };
152
+
128
153
  /**
129
154
  * @param {string} current
130
155
  * @param {string} latest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiendu",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CLI para desarrollar y publicar temas en Tiendu",
5
5
  "type": "module",
6
6
  "bin": {