tiendu 0.3.0 → 0.3.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 +21 -0
- package/bin/tiendu.js +25 -3
- package/bin/tiendu.mjs +26 -1
- package/lib/update-check.mjs +31 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,6 +144,27 @@ tiendu publish
|
|
|
144
144
|
|
|
145
145
|
---
|
|
146
146
|
|
|
147
|
+
### `tiendu check-updates`
|
|
148
|
+
|
|
149
|
+
Checks npm for a newer `tiendu` version on demand.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
tiendu check-updates
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### `tiendu --version` / `tiendu -v`
|
|
158
|
+
|
|
159
|
+
Prints the current CLI version.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
tiendu --version
|
|
163
|
+
tiendu -v
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
147
168
|
### `tiendu preview create [name]`
|
|
148
169
|
|
|
149
170
|
Creates a new remote preview.
|
package/bin/tiendu.js
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
previewDelete,
|
|
14
14
|
previewOpen,
|
|
15
15
|
} from "../lib/preview.mjs";
|
|
16
|
-
import {
|
|
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
|
|
@@ -32,7 +36,11 @@ Usage:
|
|
|
32
36
|
tiendu preview delete Delete the active preview
|
|
33
37
|
tiendu preview open Open the active preview URL in your browser
|
|
34
38
|
|
|
39
|
+
tiendu check-updates Check npm for a newer CLI version
|
|
40
|
+
tiendu version Show the current CLI version
|
|
41
|
+
|
|
35
42
|
tiendu help Show this help message
|
|
43
|
+
tiendu --version, -v Show the current CLI version
|
|
36
44
|
|
|
37
45
|
Typical workflow:
|
|
38
46
|
tiendu init my-store Set up a new project in ./my-store
|
|
@@ -48,8 +56,14 @@ const main = async () => {
|
|
|
48
56
|
const command = args[0];
|
|
49
57
|
const subcommand = args[1];
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
if (
|
|
60
|
+
command === "version" ||
|
|
61
|
+
command === "--version" ||
|
|
62
|
+
command === "-v"
|
|
63
|
+
) {
|
|
64
|
+
console.log(getCurrentVersion());
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
53
67
|
|
|
54
68
|
if (
|
|
55
69
|
!command ||
|
|
@@ -61,6 +75,14 @@ const main = async () => {
|
|
|
61
75
|
process.exit(0);
|
|
62
76
|
}
|
|
63
77
|
|
|
78
|
+
if (command === "check-updates") {
|
|
79
|
+
await checkForUpdatesNow();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check for updates at most once per day (non-blocking)
|
|
84
|
+
await checkForUpdates();
|
|
85
|
+
|
|
64
86
|
if (command === "init") {
|
|
65
87
|
await init(args[1]); // optional directory name
|
|
66
88
|
return;
|
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
|
|
@@ -27,10 +32,14 @@ Uso:
|
|
|
27
32
|
tiendu preview delete Eliminar el preview activo
|
|
28
33
|
tiendu preview open Abrir la URL del preview en el navegador
|
|
29
34
|
|
|
35
|
+
tiendu check-updates Buscar una nueva version del CLI
|
|
36
|
+
tiendu version Mostrar la version actual del CLI
|
|
37
|
+
|
|
30
38
|
tiendu help Mostrar esta ayuda
|
|
31
39
|
|
|
32
|
-
Opciones:
|
|
40
|
+
Opciones:
|
|
33
41
|
--help, -h Mostrar esta ayuda
|
|
42
|
+
--version, -v Mostrar la version actual del CLI
|
|
34
43
|
`;
|
|
35
44
|
|
|
36
45
|
const main = async () => {
|
|
@@ -38,6 +47,15 @@ const main = async () => {
|
|
|
38
47
|
const command = args[0];
|
|
39
48
|
const subcommand = args[1];
|
|
40
49
|
|
|
50
|
+
if (
|
|
51
|
+
command === "version" ||
|
|
52
|
+
command === "--version" ||
|
|
53
|
+
command === "-v"
|
|
54
|
+
) {
|
|
55
|
+
console.log(getCurrentVersion());
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
if (
|
|
42
60
|
!command ||
|
|
43
61
|
command === "help" ||
|
|
@@ -48,6 +66,13 @@ const main = async () => {
|
|
|
48
66
|
process.exit(0);
|
|
49
67
|
}
|
|
50
68
|
|
|
69
|
+
if (command === "check-updates") {
|
|
70
|
+
await checkForUpdatesNow();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
await checkForUpdates();
|
|
75
|
+
|
|
51
76
|
if (command === "init") {
|
|
52
77
|
await init();
|
|
53
78
|
return;
|
package/lib/update-check.mjs
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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
|