storyloco 1.13.2 → 1.13.4
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/package.json
CHANGED
|
@@ -137,9 +137,11 @@
|
|
|
137
137
|
* {
|
|
138
138
|
@apply border-border outline-ring/50;
|
|
139
139
|
}
|
|
140
|
+
|
|
140
141
|
body {
|
|
141
|
-
@apply bg-background text-foreground text-base;
|
|
142
|
+
@apply !bg-background text-foreground text-base;
|
|
142
143
|
}
|
|
144
|
+
|
|
143
145
|
button {
|
|
144
146
|
cursor: pointer;
|
|
145
147
|
}
|
|
@@ -157,6 +159,8 @@
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
[data-theme='dark'] {
|
|
162
|
+
color-scheme: dark;
|
|
163
|
+
|
|
160
164
|
select {
|
|
161
165
|
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
|
162
166
|
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { match, compile } from "path-to-regexp";
|
|
2
|
+
import { access, readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { cwd } from "node:process";
|
|
5
|
+
import { logger } from "./plugin.js";
|
|
2
6
|
// Lazy load the redirects map to avoid import errors during dev
|
|
3
7
|
let redirects_map = null;
|
|
4
8
|
async function load_redirects_map() {
|
|
5
9
|
if (redirects_map)
|
|
6
10
|
return redirects_map;
|
|
11
|
+
// Try to find and import the redirects file from the project root. Allow some time
|
|
12
|
+
// for the Vite plugin to generate it on first boot.
|
|
13
|
+
const project_root = cwd();
|
|
14
|
+
const redirects_file_json = join(project_root, ".svelte-kit", "storyblok", "redirects.build.json");
|
|
7
15
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
await access(redirects_file_json);
|
|
17
|
+
const content = await readFile(redirects_file_json, "utf-8");
|
|
18
|
+
const entries = JSON.parse(content);
|
|
19
|
+
redirects_map = new Map(entries);
|
|
20
|
+
return redirects_map;
|
|
11
21
|
}
|
|
12
|
-
catch (
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
catch (err) {
|
|
23
|
+
logger.warn(`Redirects file not found, using empty redirects map`);
|
|
24
|
+
logger.warn(String(err));
|
|
15
25
|
redirects_map = new Map();
|
|
16
26
|
return redirects_map;
|
|
17
27
|
}
|
|
@@ -2,9 +2,8 @@ import { loadEnv } from "vite";
|
|
|
2
2
|
import { writeFile, readFile, access, constants } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Logger } from "../shared/logger.js";
|
|
5
|
-
import * as prettier from "prettier";
|
|
6
5
|
const name = "vite-storyblok-redirects";
|
|
7
|
-
const logger = new Logger(name);
|
|
6
|
+
export const logger = new Logger(name);
|
|
8
7
|
async function get_redirects(datasource = "redirects", public_storyblok_access_token) {
|
|
9
8
|
const env_token = loadEnv("", "", "").PUBLIC_STORYBLOK_ACCESS_TOKEN;
|
|
10
9
|
const token = public_storyblok_access_token ?? env_token;
|
|
@@ -106,19 +105,20 @@ export default function redirects({ datasource = "redirects", public_storyblok_a
|
|
|
106
105
|
const run = async () => {
|
|
107
106
|
try {
|
|
108
107
|
const { datasource_entries } = await get_redirects(datasource, public_storyblok_access_token);
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const current_norm = normalize_content(formatted);
|
|
108
|
+
const output_dir = path.resolve(".svelte-kit", "storyblok");
|
|
109
|
+
const output_json = path.join(output_dir, "redirects.build.json");
|
|
110
|
+
const entries = Array.from(new Map(datasource_entries
|
|
111
|
+
.filter((e) => Boolean(e?.name) && Boolean(e?.value))
|
|
112
|
+
.map((e) => [e.name, e.value])).entries());
|
|
113
|
+
const entries_json = JSON.stringify(entries, null, 2);
|
|
114
|
+
const current_norm = normalize_content(entries_json);
|
|
117
115
|
if (current_norm !== last_written) {
|
|
118
116
|
logger.start("Generating redirects");
|
|
119
|
-
|
|
117
|
+
// ensure directory exists
|
|
118
|
+
await (await import("node:fs/promises")).mkdir(output_dir, { recursive: true });
|
|
119
|
+
await writeFile(output_json, entries_json);
|
|
120
120
|
last_written = current_norm;
|
|
121
|
-
logger.succeed("Redirects
|
|
121
|
+
logger.succeed("Redirects JSON generated");
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
catch (err) {
|
|
@@ -135,27 +135,27 @@ export default function redirects({ datasource = "redirects", public_storyblok_a
|
|
|
135
135
|
}
|
|
136
136
|
try {
|
|
137
137
|
const { datasource_entries } = await get_redirects(datasource, public_storyblok_access_token);
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const prettier_config = await prettier.resolveConfig(output);
|
|
141
|
-
const formatted = await prettier.format(ts_content, {
|
|
142
|
-
...(prettier_config ?? {}),
|
|
143
|
-
filepath: output,
|
|
144
|
-
});
|
|
138
|
+
const output_dir = path.resolve(".svelte-kit", "storyblok");
|
|
139
|
+
const output_json = path.join(output_dir, "redirects.build.json");
|
|
145
140
|
let previous = "";
|
|
146
141
|
try {
|
|
147
|
-
await access(
|
|
148
|
-
previous = await readFile(
|
|
142
|
+
await access(output_json, constants.F_OK);
|
|
143
|
+
previous = await readFile(output_json, "utf8");
|
|
149
144
|
}
|
|
150
145
|
catch {
|
|
151
146
|
// file doesn't exist, that's fine
|
|
152
147
|
}
|
|
148
|
+
const entries = Array.from(new Map(datasource_entries
|
|
149
|
+
.filter((e) => Boolean(e?.name) && Boolean(e?.value))
|
|
150
|
+
.map((e) => [e.name, e.value])).entries());
|
|
151
|
+
const entries_json = JSON.stringify(entries, null, 2);
|
|
153
152
|
const previous_norm = normalize_content(previous);
|
|
154
|
-
const current_norm = normalize_content(
|
|
153
|
+
const current_norm = normalize_content(entries_json);
|
|
155
154
|
if (previous_norm !== current_norm) {
|
|
156
155
|
logger.start("Generating redirects");
|
|
157
|
-
await
|
|
158
|
-
|
|
156
|
+
await (await import("node:fs/promises")).mkdir(output_dir, { recursive: true });
|
|
157
|
+
await writeFile(output_json, entries_json);
|
|
158
|
+
logger.succeed("Redirects JSON generated");
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
catch (err) {
|
|
@@ -166,31 +166,3 @@ export default function redirects({ datasource = "redirects", public_storyblok_a
|
|
|
166
166
|
closeBundle() { },
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function generate_ts_file(entries) {
|
|
170
|
-
const map_entries = entries
|
|
171
|
-
.filter((e) => Boolean(e?.name) && Boolean(e?.value))
|
|
172
|
-
.map((e) => `\t[${JSON.stringify(e.name)}, ${JSON.stringify(e.value)}]`)
|
|
173
|
-
.join(",\n");
|
|
174
|
-
return `/**
|
|
175
|
-
* AUTO-GENERATED FILE. DO NOT EDIT.
|
|
176
|
-
* Generated by ${name} plugin on ${new Date().toISOString()}.
|
|
177
|
-
* Any changes will be overwritten.
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Redirects map
|
|
182
|
-
*
|
|
183
|
-
* Maps a source pathname pattern to a target pathname template.
|
|
184
|
-
*
|
|
185
|
-
* - key: source pattern (supports '*' as a single-segment wildcard)
|
|
186
|
-
* - value: target template (each '*' is replaced by the corresponding capture)
|
|
187
|
-
*
|
|
188
|
-
* Notes:
|
|
189
|
-
* - Keys may be provided without a leading slash (e.g. foo == /foo).
|
|
190
|
-
* - Self-redirects (target resolves to the same pathname) are ignored.
|
|
191
|
-
*/
|
|
192
|
-
export const redirects_map: Map<string, string> = new Map([
|
|
193
|
-
${map_entries}
|
|
194
|
-
])
|
|
195
|
-
`;
|
|
196
|
-
}
|
|
@@ -129,7 +129,7 @@ export default function schema({ output_path, interval_ms, storyblok_personal_ac
|
|
|
129
129
|
// Generate types
|
|
130
130
|
logger.start("Generating TypeScript definitions...");
|
|
131
131
|
await $ `chmod u+w ${schema_ts_file}`.quiet().nothrow();
|
|
132
|
-
await $ `${x} storyblok@4.6.6 ts generate -s ${storyblok_space_id} -p .svelte-kit/storyblok --compiler-options ${here("compiler_options.js")} --custom-fields-parser ${here("custom_fields_parser.js")} --strict
|
|
132
|
+
await $ `${x} storyblok@4.6.6 ts generate -s ${storyblok_space_id} -p .svelte-kit/storyblok --compiler-options ${here("compiler_options.js")} --custom-fields-parser ${here("custom_fields_parser.js")} --strict`.quiet();
|
|
133
133
|
logger.succeed("TypeScript definitions generated.");
|
|
134
134
|
// Get generated files
|
|
135
135
|
let component_types;
|