@spicemod/creator 0.0.1 → 0.0.21
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/dist/bin.mjs +38 -1
- package/dist/client/index.d.mts +8 -0
- package/dist/templates/wrapper.js +2 -2
- package/package.json +1 -1
- package/templates/wrapper.js +2 -2
package/dist/bin.mjs
CHANGED
|
@@ -135,7 +135,7 @@ const templateFilePath = dist("templates/wrapper.js", import.meta.url);
|
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
137
|
var name = "@spicemod/creator";
|
|
138
|
-
var version = "0.0.
|
|
138
|
+
var version = "0.0.21";
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/utils/common.ts
|
|
@@ -262,6 +262,7 @@ const CommonSchema = v.object({
|
|
|
262
262
|
framework: v.picklist(frameworkTypes),
|
|
263
263
|
packageManager: v.picklist(packageManagers),
|
|
264
264
|
esbuildOptions: v.record(v.string(), v.any()),
|
|
265
|
+
devModeVarName: v.optional(v.string()),
|
|
265
266
|
serverConfig: v.partial(ServerConfigSchema),
|
|
266
267
|
version: v.string()
|
|
267
268
|
});
|
|
@@ -286,6 +287,7 @@ const DISCORD_LINK = "https://discord.gg/YGkktjdYV8";
|
|
|
286
287
|
const DOCS_LINK = "https://github.com/sanoojes/spicetify-creator";
|
|
287
288
|
const CONFIG_REF_LINK = "https://github.com/sanoojes/spicetify-creator";
|
|
288
289
|
const SPICETIFY_LINK = "https://spicetify.app/docs/getting-started";
|
|
290
|
+
const DEV_MODE_VAR_NAME = `__SPICE_CREATOR_DEV__`;
|
|
289
291
|
const CHECK = pc.bold(pc.green("✔"));
|
|
290
292
|
const CROSS = pc.bold(pc.red("✖"));
|
|
291
293
|
const WARN = pc.bold(pc.yellow("⚠"));
|
|
@@ -664,6 +666,7 @@ function validateSpicetify(bin) {
|
|
|
664
666
|
|
|
665
667
|
//#endregion
|
|
666
668
|
//#region src/esbuild/plugins/spicetifyHandlers.ts
|
|
669
|
+
const skipSpicetify = process.env.SPICETIFY_SKIP === "true" || process.env.CI === "true";
|
|
667
670
|
const spicetifyHandler = ({ config, options, cache, logger = createLogger("plugin:spicetifyHandler") }) => ({
|
|
668
671
|
name: "spice_internal__spicetify-build-handler",
|
|
669
672
|
async setup(build) {
|
|
@@ -671,6 +674,30 @@ const spicetifyHandler = ({ config, options, cache, logger = createLogger("plugi
|
|
|
671
674
|
let hasAppliedOnce = false;
|
|
672
675
|
const isExtension = config.template === "extension";
|
|
673
676
|
const identifier = isExtension ? `${urlSlugify(config.name)}.js` : urlSlugify(config.name);
|
|
677
|
+
if (skipSpicetify) {
|
|
678
|
+
logger.info(pc.yellow("SPICETIFY_SKIP=true, skipping spicetify operations"));
|
|
679
|
+
build.onEnd(async (result) => {
|
|
680
|
+
if (result.errors.length > 0) return;
|
|
681
|
+
if (!cache.hasChanges || cache.changed.size === 0) return;
|
|
682
|
+
const tasks = [];
|
|
683
|
+
for (const filePath of cache.changed) {
|
|
684
|
+
const fileData = cache.files.get(filePath);
|
|
685
|
+
if (!fileData) continue;
|
|
686
|
+
const targetPath = resolve(outDir, basename(filePath));
|
|
687
|
+
tasks.push((async () => {
|
|
688
|
+
await mkdirp(outDir);
|
|
689
|
+
await writeFile(targetPath, fileData.contents);
|
|
690
|
+
})());
|
|
691
|
+
}
|
|
692
|
+
try {
|
|
693
|
+
await Promise.all(tasks);
|
|
694
|
+
logger.debug(pc.green(`${CHECK} Built files written to ${outDir}`));
|
|
695
|
+
} catch (err) {
|
|
696
|
+
logger.error(pc.red(`${CROSS} Failed to write files: ${err instanceof Error ? err.message : String(err)}`));
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
674
701
|
const spiceConfig = await getSpicetifyConfig();
|
|
675
702
|
logger.debug(pc.green("Spicetify Config: "), spiceConfig);
|
|
676
703
|
if (apply) {
|
|
@@ -919,6 +946,11 @@ function getJSBuildOptions(config, options) {
|
|
|
919
946
|
"react",
|
|
920
947
|
"react-dom"
|
|
921
948
|
],
|
|
949
|
+
define: {
|
|
950
|
+
[DEV_MODE_VAR_NAME]: "false",
|
|
951
|
+
...config.devModeVarName ? { [config.devModeVarName]: "false" } : {},
|
|
952
|
+
...config.esbuildOptions.define
|
|
953
|
+
},
|
|
922
954
|
plugins: [...config.esbuildOptions?.plugins ? config.esbuildOptions.plugins : [], ...getCommonPlugins({
|
|
923
955
|
...config,
|
|
924
956
|
minify,
|
|
@@ -1699,6 +1731,11 @@ function getJSDevOptions(config, options) {
|
|
|
1699
1731
|
"react",
|
|
1700
1732
|
"react-dom"
|
|
1701
1733
|
],
|
|
1734
|
+
define: {
|
|
1735
|
+
[DEV_MODE_VAR_NAME]: "true",
|
|
1736
|
+
...config.devModeVarName ? { [config.devModeVarName]: "true" } : {},
|
|
1737
|
+
...config.esbuildOptions.define
|
|
1738
|
+
},
|
|
1702
1739
|
plugins: [...config.esbuildOptions?.plugins ? config.esbuildOptions.plugins : [], ...getCommonPlugins({
|
|
1703
1740
|
...config,
|
|
1704
1741
|
minify,
|
package/dist/client/index.d.mts
CHANGED
|
@@ -14,6 +14,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
14
14
|
readonly framework: v.PicklistSchema<readonly ["react", "vanilla"], undefined>;
|
|
15
15
|
readonly packageManager: v.PicklistSchema<PackageManagerType[], undefined>;
|
|
16
16
|
readonly esbuildOptions: v.GenericSchema<ESBuildOptions>;
|
|
17
|
+
readonly devModeVarName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
17
18
|
readonly serverConfig: Omit<v.ObjectSchema<{
|
|
18
19
|
readonly port: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
19
20
|
readonly serveDir: v.StringSchema<undefined>;
|
|
@@ -61,6 +62,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
61
62
|
readonly framework: v.OptionalSchema<v.PicklistSchema<readonly ["react", "vanilla"], undefined>, undefined>;
|
|
62
63
|
readonly packageManager: v.OptionalSchema<v.PicklistSchema<PackageManagerType[], undefined>, undefined>;
|
|
63
64
|
readonly esbuildOptions: v.OptionalSchema<v.GenericSchema<ESBuildOptions>, undefined>;
|
|
65
|
+
readonly devModeVarName: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
64
66
|
readonly serverConfig: v.OptionalSchema<Omit<v.ObjectSchema<{
|
|
65
67
|
readonly port: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
66
68
|
readonly serveDir: v.StringSchema<undefined>;
|
|
@@ -108,6 +110,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
108
110
|
framework?: "react" | "vanilla" | undefined;
|
|
109
111
|
packageManager?: PackageManagerType | undefined;
|
|
110
112
|
esbuildOptions?: ESBuildOptions | undefined;
|
|
113
|
+
devModeVarName?: string | undefined;
|
|
111
114
|
serverConfig?: {
|
|
112
115
|
port?: number | undefined;
|
|
113
116
|
serveDir?: string | undefined;
|
|
@@ -121,6 +124,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
121
124
|
framework?: "react" | "vanilla" | undefined;
|
|
122
125
|
packageManager?: PackageManagerType | undefined;
|
|
123
126
|
esbuildOptions?: ESBuildOptions | undefined;
|
|
127
|
+
devModeVarName?: string | undefined;
|
|
124
128
|
serverConfig?: {
|
|
125
129
|
port?: number | undefined;
|
|
126
130
|
serveDir?: string | undefined;
|
|
@@ -135,6 +139,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
135
139
|
framework?: "react" | "vanilla" | undefined;
|
|
136
140
|
packageManager?: PackageManagerType | undefined;
|
|
137
141
|
esbuildOptions?: ESBuildOptions | undefined;
|
|
142
|
+
devModeVarName?: string | undefined;
|
|
138
143
|
serverConfig?: {
|
|
139
144
|
port?: number | undefined;
|
|
140
145
|
serveDir?: string | undefined;
|
|
@@ -150,6 +155,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
150
155
|
framework?: "react" | "vanilla" | undefined;
|
|
151
156
|
packageManager?: PackageManagerType | undefined;
|
|
152
157
|
esbuildOptions?: ESBuildOptions | undefined;
|
|
158
|
+
devModeVarName?: string | undefined;
|
|
153
159
|
serverConfig?: {
|
|
154
160
|
port?: number | undefined;
|
|
155
161
|
serveDir?: string | undefined;
|
|
@@ -164,6 +170,7 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
|
|
|
164
170
|
framework?: "react" | "vanilla" | undefined;
|
|
165
171
|
packageManager?: PackageManagerType | undefined;
|
|
166
172
|
esbuildOptions?: ESBuildOptions | undefined;
|
|
173
|
+
devModeVarName?: string | undefined;
|
|
167
174
|
serverConfig?: {
|
|
168
175
|
port?: number | undefined;
|
|
169
176
|
serveDir?: string | undefined;
|
|
@@ -2167,6 +2174,7 @@ declare namespace _Spicetify {
|
|
|
2167
2174
|
}
|
|
2168
2175
|
declare global {
|
|
2169
2176
|
const Spicetify: typeof _Spicetify;
|
|
2177
|
+
const __SPICE_CREATOR_DEV__: boolean;
|
|
2170
2178
|
}
|
|
2171
2179
|
//#endregion
|
|
2172
2180
|
//#region src/client/index.d.ts
|
|
@@ -8,7 +8,7 @@ __ESBUILD__HAS_CSS &&
|
|
|
8
8
|
style.textContent = css;
|
|
9
9
|
document.head.appendChild(style);
|
|
10
10
|
}
|
|
11
|
-
} catch {
|
|
11
|
+
} catch {}
|
|
12
12
|
})();
|
|
13
13
|
(async () => {
|
|
14
14
|
const _ID = `${__ESBUILD__APP_SLUG}-${__ESBUILD__APP_TYPE}`;
|
|
@@ -45,4 +45,4 @@ __ESBUILD__HAS_CSS &&
|
|
|
45
45
|
window.Spicetify?.showNotification(`⚠️ ${appId}: ${msg} (check console for more info)`, true);
|
|
46
46
|
console.error(`[${appId}] Error:`, err);
|
|
47
47
|
}
|
|
48
|
-
})();
|
|
48
|
+
})();
|
package/package.json
CHANGED
package/templates/wrapper.js
CHANGED
|
@@ -8,7 +8,7 @@ __ESBUILD__HAS_CSS &&
|
|
|
8
8
|
style.textContent = css;
|
|
9
9
|
document.head.appendChild(style);
|
|
10
10
|
}
|
|
11
|
-
} catch {
|
|
11
|
+
} catch {}
|
|
12
12
|
})();
|
|
13
13
|
(async () => {
|
|
14
14
|
const _ID = `${__ESBUILD__APP_SLUG}-${__ESBUILD__APP_TYPE}`;
|
|
@@ -45,4 +45,4 @@ __ESBUILD__HAS_CSS &&
|
|
|
45
45
|
window.Spicetify?.showNotification(`⚠️ ${appId}: ${msg} (check console for more info)`, true);
|
|
46
46
|
console.error(`[${appId}] Error:`, err);
|
|
47
47
|
}
|
|
48
|
-
})();
|
|
48
|
+
})();
|