@windwalker-io/core 4.2.0 → 4.2.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/dist/next.js ADDED
@@ -0,0 +1,537 @@
1
+ import { getGlobBaseFromPattern, callback, css, js, shortHash, plugin, callbackAfterBuild, copyGlob, symlink } from "@windwalker-io/fusion-next";
2
+ import isGlob from "is-glob";
3
+ import micromatch from "micromatch";
4
+ import path, { relative, normalize, resolve } from "node:path";
5
+ import fs from "node:fs";
6
+ import fg from "fast-glob";
7
+ import crypto, { randomBytes } from "node:crypto";
8
+ import { createRequire } from "node:module";
9
+ import fs$1 from "fs-extra";
10
+ import { parse } from "node-html-parser";
11
+ function loadJson(file) {
12
+ if (!fs.existsSync(file)) {
13
+ return null;
14
+ }
15
+ return JSON.parse(fs.readFileSync(file, "utf8"));
16
+ }
17
+ function containsMiddleGlob(str) {
18
+ return isGlob(removeLastGlob(str));
19
+ }
20
+ function removeLastGlob(str) {
21
+ return str.replace(/(\/\*|\/\*\*?|\*\*\/\*?)$/, "");
22
+ }
23
+ const ds = process.platform === "win32" ? "\\" : "/";
24
+ function ensureDirPath(path2, slash = ds) {
25
+ if (!path2.endsWith(slash)) {
26
+ return path2 + slash;
27
+ }
28
+ return path2;
29
+ }
30
+ function findFilesFromGlobArray(sources) {
31
+ let files = [];
32
+ for (const source of sources) {
33
+ files = [
34
+ ...files,
35
+ ...findFiles(source)
36
+ ];
37
+ }
38
+ return files;
39
+ }
40
+ function findFiles(src) {
41
+ return fg.globSync(src).map((file) => {
42
+ file = file.replace(/\\/g, "/");
43
+ return {
44
+ fullpath: file,
45
+ relativePath: relative(getGlobBaseFromPattern(src), file).replace(/\\/g, "/")
46
+ };
47
+ });
48
+ }
49
+ function findModules(suffix = "", rootModule = "src/Module") {
50
+ const pkg = path.resolve(process.cwd(), "composer.json");
51
+ const pkgJson = loadJson(pkg);
52
+ const vendors = Object.keys(pkgJson["require"] || {}).concat(Object.keys(pkgJson["require-dev"] || {})).map((id) => `vendor/${id}/composer.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.extra?.windwalker != null).map((pkgJson2) => {
53
+ return pkgJson2?.extra?.windwalker?.modules?.map((module) => {
54
+ return `vendor/${pkgJson2.name}/${module}/${suffix}`;
55
+ }) || [];
56
+ }).flat();
57
+ if (rootModule) {
58
+ vendors.unshift(rootModule + "/" + suffix);
59
+ }
60
+ return [...new Set(vendors)];
61
+ }
62
+ function findPackages(suffix = "", withRoot = true) {
63
+ const pkg = path.resolve(process.cwd(), "composer.json");
64
+ const pkgJson = loadJson(pkg);
65
+ const vendors = Object.keys(pkgJson["require"] || {}).concat(Object.keys(pkgJson["require-dev"] || {})).map((id) => `vendor/${id}/composer.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.extra?.windwalker != null).map((pkgJson2) => `vendor/${pkgJson2.name}/${suffix}`).flat();
66
+ if (withRoot) {
67
+ vendors.unshift(suffix);
68
+ }
69
+ return [...new Set(vendors)];
70
+ }
71
+ function uniqId(prefix = "", size = 16) {
72
+ let id = randomBytes(size).toString("hex");
73
+ if (prefix) {
74
+ id = prefix + id;
75
+ }
76
+ return id;
77
+ }
78
+ function resolveModuleRealpath(url, module) {
79
+ const require2 = createRequire(url);
80
+ return require2.resolve(module);
81
+ }
82
+ function stripUrlQuery(src) {
83
+ const qPos = src.indexOf("?");
84
+ if (qPos !== -1) {
85
+ return src.substring(0, qPos);
86
+ }
87
+ return src;
88
+ }
89
+ function cloneAssets(patterns) {
90
+ return callback((taskName, builder) => {
91
+ const reposition = getAvailableForReposition(patterns);
92
+ handleReposition(builder, reposition);
93
+ handleCloneAssets(builder, Object.keys(patterns));
94
+ return null;
95
+ });
96
+ }
97
+ function getAvailableForReposition(patterns) {
98
+ const reposition = {};
99
+ for (const from in patterns) {
100
+ if (!containsMiddleGlob(from)) {
101
+ reposition[from] = patterns[from];
102
+ }
103
+ }
104
+ return reposition;
105
+ }
106
+ function handleCloneAssets(builder, clonePatterns) {
107
+ const id = uniqId("hidden:clone-asset-") + ".js";
108
+ builder.addTask(id);
109
+ builder.resolveIdCallbacks.push((src) => {
110
+ if (src === id) {
111
+ return id;
112
+ }
113
+ });
114
+ builder.loadCallbacks.push((src) => {
115
+ if (src === id) {
116
+ const glob = clonePatterns.map((v) => v.replace(/\\/g, "/")).map((v) => v.startsWith("./") || !v.startsWith("/") ? `/${v}` : v).map((v) => `'${v}'`).join(", ");
117
+ return `import.meta.glob(${glob});
118
+ `;
119
+ }
120
+ });
121
+ }
122
+ function handleReposition(builder, reposition) {
123
+ builder.assetFileNamesCallbacks.push((assetInfo) => {
124
+ const fileName = assetInfo.originalFileName;
125
+ for (const base in reposition) {
126
+ if (match(fileName, base)) {
127
+ return normalize(reposition[base] + relative(removeLastGlob(base), fileName)).replace(/\\/g, "/");
128
+ }
129
+ }
130
+ });
131
+ }
132
+ function match(str, pattern) {
133
+ if (isGlob(pattern)) {
134
+ return micromatch.isMatch(str, pattern);
135
+ }
136
+ return str.startsWith(pattern);
137
+ }
138
+ function globalAssets(options) {
139
+ return {
140
+ name: "core:global-assets",
141
+ buildConfig(builder) {
142
+ const clone = options.clone || {};
143
+ let reposition = options.reposition || {};
144
+ reposition = { ...reposition, ...getAvailableForReposition(clone) };
145
+ handleReposition(builder, reposition);
146
+ const clonePatterns = Object.keys(clone);
147
+ if (clonePatterns.length > 0) {
148
+ handleCloneAssets(builder, clonePatterns);
149
+ }
150
+ }
151
+ };
152
+ }
153
+ function injectSystemJS(systemPath, filter) {
154
+ systemPath ??= resolve("node_modules/systemjs/dist/system.min.js");
155
+ return {
156
+ name: "core:inject-systemjs",
157
+ async generateBundle(options, bundle) {
158
+ if (options.format !== "system") {
159
+ return;
160
+ }
161
+ const systemjsCode = fs$1.readFileSync(
162
+ resolve(systemPath),
163
+ "utf-8"
164
+ );
165
+ for (const file of Object.values(bundle)) {
166
+ if (filter && !filter(file)) {
167
+ continue;
168
+ }
169
+ if (file.type === "chunk" && file.isEntry && file.fileName.endsWith(".js")) {
170
+ file.code = systemjsCode + "\n" + file.code;
171
+ }
172
+ }
173
+ }
174
+ };
175
+ }
176
+ function systemCSSFix() {
177
+ return {
178
+ name: "core:systemjs-css-fix",
179
+ async generateBundle(options, bundle) {
180
+ if (options.format !== "system") {
181
+ return;
182
+ }
183
+ for (const [fileName, chunk] of Object.entries(bundle)) {
184
+ if (fileName.endsWith(".css") && "code" in chunk) {
185
+ const regex = /__vite_style__\.textContent\s*=\s*"([\s\S]*?)";/;
186
+ let match2 = chunk.code.match(regex);
187
+ if (!match2) {
188
+ const regex2 = /\.textContent\s*=\s*`([\s\S]*?)`/;
189
+ match2 = chunk.code.match(regex2);
190
+ }
191
+ if (match2 && match2[1]) {
192
+ chunk.code = match2[1].replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\\\/g, "\\").replace(/\/\*\$vite\$:\d+\*\/$/, "");
193
+ }
194
+ }
195
+ }
196
+ }
197
+ };
198
+ }
199
+ function cssModulize(entry, dest) {
200
+ return new CssModulizeProcessor(css(entry, dest));
201
+ }
202
+ class CssModulizeProcessor {
203
+ constructor(processor, bladePatterns = [], cssPatterns = []) {
204
+ this.processor = processor;
205
+ this.bladePatterns = bladePatterns;
206
+ this.cssPatterns = cssPatterns;
207
+ }
208
+ parseBlades(...bladePatterns) {
209
+ this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
210
+ return this;
211
+ }
212
+ mergeCss(...css2) {
213
+ this.cssPatterns = this.cssPatterns.concat(css2.flat());
214
+ return this;
215
+ }
216
+ config(taskName, builder) {
217
+ const tasks = this.processor.config(taskName, builder);
218
+ const task = tasks[0];
219
+ const inputFile = resolve(task.input);
220
+ const bladeFiles = fg.globSync(this.bladePatterns);
221
+ for (const file of bladeFiles) {
222
+ builder.watches.push({
223
+ file,
224
+ moduleFile: inputFile,
225
+ updateType: "css-update"
226
+ });
227
+ }
228
+ builder.loadCallbacks.push((src, options) => {
229
+ const file = stripUrlQuery(src);
230
+ if (normalize(file) === inputFile) {
231
+ const patterns = fg.globSync(
232
+ this.cssPatterns.map((v) => resolve(v)).map((v) => v.replace(/\\/g, "/"))
233
+ );
234
+ const imports = patterns.map((pattern) => `@import "${pattern}";`).concat(this.parseStylesFromBlades(bladeFiles)).join("\n");
235
+ let main = fs$1.readFileSync(file, "utf-8");
236
+ main += `
237
+
238
+ ${imports}
239
+ `;
240
+ return main;
241
+ }
242
+ });
243
+ return void 0;
244
+ }
245
+ parseStylesFromBlades(files) {
246
+ return files.map((file) => {
247
+ const bladeText = fs$1.readFileSync(file, "utf8");
248
+ const html = parse(bladeText);
249
+ return html.querySelectorAll("style[type][data-macro],script[type][data-macro]").filter(
250
+ (el) => ["text/scss", "text/css"].includes(el.getAttribute("type") || "")
251
+ ).map((el) => {
252
+ const scope = el.getAttribute("data-scope");
253
+ if (scope) {
254
+ return `${scope} {
255
+ ${el.innerHTML}
256
+ }`;
257
+ } else {
258
+ return el.innerHTML;
259
+ }
260
+ });
261
+ }).filter((c) => c.length > 0).flat();
262
+ }
263
+ preview() {
264
+ return [];
265
+ }
266
+ }
267
+ function jsModulize(entry, dest, options = {}) {
268
+ return new JsModulizeProcessor(js(entry, dest), options);
269
+ }
270
+ class JsModulizeProcessor {
271
+ constructor(processor, options = {}) {
272
+ this.processor = processor;
273
+ this.options = options;
274
+ }
275
+ scriptPatterns = [];
276
+ bladePatterns = [];
277
+ stagePrefix = "";
278
+ config(taskName, builder) {
279
+ const tasks = this.processor.config(taskName, builder);
280
+ const task = tasks[0];
281
+ const inputFile = resolve(task.input);
282
+ const tmpPath = this.options.tmpPath ?? resolve("./tmp/fusion/jsmodules/").replace(/\\/g, "/");
283
+ const clean = this.options.cleanTmp ?? true;
284
+ if (clean) {
285
+ builder.postBuildCallbacks.push((options, bundle) => {
286
+ fs$1.removeSync(tmpPath);
287
+ });
288
+ }
289
+ this.ignoreMainImport(task);
290
+ builder.resolveIdCallbacks.push((id) => {
291
+ if (id === "@main") {
292
+ return { id, external: true };
293
+ }
294
+ });
295
+ const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
296
+ const bladeFiles = parseScriptsFromBlades(this.bladePatterns);
297
+ builder.loadCallbacks.push((src, options) => {
298
+ const srcFile = stripUrlQuery(src);
299
+ if (normalize(srcFile) === inputFile) {
300
+ let listJS = "{\n";
301
+ for (const scriptFile of scriptFiles) {
302
+ let fullpath = scriptFile.fullpath;
303
+ if (fullpath.endsWith(".d.ts")) {
304
+ continue;
305
+ }
306
+ let key = scriptFile.relativePath.replace(/assets\//, "").toLowerCase();
307
+ fullpath = resolve(fullpath).replace(/\\/g, "/");
308
+ key = key.substring(0, key.lastIndexOf("."));
309
+ if (this.stagePrefix) {
310
+ key = this.stagePrefix + "/" + key;
311
+ }
312
+ key = "view:" + crypto.createHash("md5").update(key).digest("hex");
313
+ listJS += `'${key}': () => import('${fullpath}'),
314
+ `;
315
+ }
316
+ const listens = [];
317
+ fs$1.ensureDirSync(tmpPath);
318
+ for (const result of bladeFiles) {
319
+ let key = result.as;
320
+ const tmpFile = tmpPath + "/" + result.path.replace(/\\|\//g, "_") + "-" + shortHash(result.code) + ".ts";
321
+ if (!fs$1.existsSync(tmpFile) || fs$1.readFileSync(tmpFile, "utf8") !== result.code) {
322
+ fs$1.writeFileSync(tmpFile, result.code);
323
+ }
324
+ listJS += `'inline:${key}': () => import('${tmpFile}'),
325
+ `;
326
+ const fullpath = resolve(result.file.fullpath).replace(/\\/g, "/");
327
+ if (!listens.includes(fullpath)) {
328
+ listens.push(fullpath);
329
+ }
330
+ }
331
+ listJS += "}";
332
+ builder.watches.push(...listens);
333
+ let { code, comments } = stripComments(fs$1.readFileSync(srcFile, "utf-8"));
334
+ code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
335
+ return restoreComments(code, comments);
336
+ }
337
+ });
338
+ return void 0;
339
+ }
340
+ /**
341
+ * @see https://github.com/vitejs/vite/issues/6393#issuecomment-1006819717
342
+ * @see https://stackoverflow.com/questions/76259677/vite-dev-server-throws-error-when-resolving-external-path-from-importmap
343
+ */
344
+ ignoreMainImport(task) {
345
+ const VALID_ID_PREFIX = `/@id/`;
346
+ const importKeys = ["@main"];
347
+ const reg = new RegExp(
348
+ `${VALID_ID_PREFIX}(${importKeys.join("|")})`,
349
+ "g"
350
+ );
351
+ plugin({
352
+ name: "keep-main-external-" + task.id,
353
+ transform(code) {
354
+ return reg.test(code) ? code.replace(reg, (m, s1) => s1) : code;
355
+ }
356
+ });
357
+ }
358
+ preview() {
359
+ return [];
360
+ }
361
+ mergeScripts(...patterns) {
362
+ this.scriptPatterns = this.scriptPatterns.concat(patterns.flat());
363
+ return this;
364
+ }
365
+ parseBlades(...bladePatterns) {
366
+ this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
367
+ return this;
368
+ }
369
+ stage(stage) {
370
+ this.stagePrefix = stage;
371
+ return this;
372
+ }
373
+ }
374
+ function parseScriptsFromBlades(patterns) {
375
+ let files = findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
376
+ return files.map((file) => {
377
+ const bladeText = fs$1.readFileSync(file.fullpath, "utf8");
378
+ const html = parse(bladeText);
379
+ return html.querySelectorAll("script[lang][data-macro]").filter(
380
+ (el) => ["ts", "typescript"].includes(el.getAttribute("lang") || "")
381
+ ).map((el) => ({
382
+ as: el.getAttribute("data-macro") || "",
383
+ file,
384
+ path: file.relativePath.replace(/.blade.php$/, ""),
385
+ code: el.innerHTML
386
+ })).filter((c) => c.code.trim() !== "");
387
+ }).flat();
388
+ }
389
+ function stripComments(code) {
390
+ const comments = [];
391
+ let i = 0;
392
+ code = code.replace(/\/\*[\s\S]*?\*\//g, (match2) => {
393
+ const key = `__COMMENT_BLOCK_${i}__`;
394
+ comments.push({ key, value: match2 });
395
+ i++;
396
+ return key;
397
+ }).replace(/\/\/.*$/gm, (match2) => {
398
+ const key = `__COMMENT_LINE_${i}__`;
399
+ comments.push({ key, value: match2 });
400
+ i++;
401
+ return key;
402
+ });
403
+ return { code, comments };
404
+ }
405
+ function restoreComments(code, comments) {
406
+ for (const { key, value } of comments) {
407
+ const re = new RegExp(key, "g");
408
+ code = code.replace(re, value);
409
+ }
410
+ return code;
411
+ }
412
+ function installVendors(npmVendors = [], to = "www/assets/vendor") {
413
+ return callbackAfterBuild(() => findAndInstall(npmVendors, to));
414
+ }
415
+ async function findAndInstall(npmVendors = [], to = "www/assets/vendor") {
416
+ const root = to;
417
+ let vendors = npmVendors;
418
+ const action = process.env.INSTALL_VENDOR === "hard" ? "Copy" : "Link";
419
+ console.log("");
420
+ if (!fs$1.existsSync(root)) {
421
+ fs$1.mkdirSync(root);
422
+ }
423
+ const dirs = fs$1.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((dir) => path.join(root, dir.name));
424
+ dirs.unshift(root);
425
+ dirs.forEach((dir) => {
426
+ deleteExists(dir);
427
+ });
428
+ const composerJsons = getInstalledComposerVendors().map((cv) => `vendor/${cv}/composer.json`).map((file) => loadJson(file)).filter((composerJson) => composerJson?.extra?.windwalker != null);
429
+ vendors = findNpmVendors(composerJsons).concat(vendors);
430
+ vendors = [...new Set(vendors)];
431
+ for (const vendor of vendors) {
432
+ const source = `node_modules/${vendor}/`;
433
+ if (fs$1.existsSync(source)) {
434
+ console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
435
+ doInstall(source, `${root}/${vendor}/`);
436
+ }
437
+ }
438
+ for (const composerJson of composerJsons) {
439
+ const vendorName = composerJson.name;
440
+ let assets = composerJson?.extra?.windwalker?.assets?.link;
441
+ if (!assets) {
442
+ continue;
443
+ }
444
+ if (!assets.endsWith("/")) {
445
+ assets += "/";
446
+ }
447
+ if (fs$1.existsSync(`vendor/${vendorName}/${assets}`)) {
448
+ console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
449
+ doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
450
+ }
451
+ }
452
+ const staticVendorDir = "resources/assets/vendor/";
453
+ if (fs$1.existsSync(staticVendorDir)) {
454
+ const staticVendors = fs$1.readdirSync(staticVendorDir);
455
+ for (const staticVendor of staticVendors) {
456
+ if (staticVendor.startsWith("@")) {
457
+ const subVendors = fs$1.readdirSync(staticVendorDir + staticVendor);
458
+ for (const subVendor of subVendors) {
459
+ const subVendorName = staticVendor + "/" + subVendor;
460
+ const source = staticVendorDir + subVendorName + "/";
461
+ if (fs$1.existsSync(source)) {
462
+ console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
463
+ doInstall(source, `${root}/${subVendorName}/`);
464
+ }
465
+ }
466
+ } else {
467
+ let source = staticVendorDir + staticVendor;
468
+ if (fs$1.existsSync(source)) {
469
+ console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
470
+ doInstall(source, `${root}/${staticVendor}/`);
471
+ }
472
+ }
473
+ }
474
+ }
475
+ }
476
+ async function doInstall(source, dest) {
477
+ if (process.env.INSTALL_VENDOR === "hard") {
478
+ await copyGlob(source + "/**/*", dest);
479
+ } else {
480
+ await symlink(source, dest);
481
+ }
482
+ }
483
+ function findNpmVendors(composerJsons = []) {
484
+ const pkg = path.resolve(process.cwd(), "package.json");
485
+ const pkgJson = loadJson(pkg);
486
+ let vendors = Object.keys(pkgJson.devDependencies || {}).concat(Object.keys(pkgJson.dependencies || {})).map((id) => `node_modules/${id}/package.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.windwalker != null).map((pkgJson2) => pkgJson2?.windwalker.vendors || []).flat();
487
+ const vendorsFromComposer = composerJsons.map((composerJson) => {
488
+ return [
489
+ ...composerJson?.extra?.windwalker?.asset_vendors || [],
490
+ ...composerJson?.extra?.windwalker?.assets?.exposes || [],
491
+ ...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
492
+ ];
493
+ }).flat();
494
+ return [...new Set(vendors.concat(vendorsFromComposer))];
495
+ }
496
+ function getInstalledComposerVendors() {
497
+ const composerFile = path.resolve(process.cwd(), "composer.json");
498
+ const composerJson = loadJson(composerFile);
499
+ return [
500
+ ...new Set(
501
+ Object.keys(composerJson["require"] || {}).concat(Object.keys(composerJson["require-dev"] || {}))
502
+ )
503
+ ];
504
+ }
505
+ function deleteExists(dir) {
506
+ if (!fs$1.existsSync(dir)) {
507
+ return;
508
+ }
509
+ const subDirs = fs$1.readdirSync(dir, { withFileTypes: true });
510
+ for (const subDir of subDirs) {
511
+ if (subDir.isSymbolicLink() || subDir.isFile()) {
512
+ fs$1.unlinkSync(path.join(dir, subDir.name));
513
+ } else if (subDir.isDirectory()) {
514
+ deleteExists(path.join(dir, subDir.name));
515
+ }
516
+ }
517
+ fs$1.rmdirSync(dir);
518
+ }
519
+ export {
520
+ cloneAssets,
521
+ containsMiddleGlob,
522
+ cssModulize,
523
+ ensureDirPath,
524
+ findFilesFromGlobArray,
525
+ findModules,
526
+ findPackages,
527
+ globalAssets,
528
+ injectSystemJS,
529
+ installVendors,
530
+ jsModulize,
531
+ loadJson,
532
+ removeLastGlob,
533
+ resolveModuleRealpath,
534
+ stripUrlQuery,
535
+ systemCSSFix,
536
+ uniqId
537
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windwalker-io/core",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "type": "module",
5
5
  "description": "Windwalker Core JS package",
6
6
  "scripts": {
@@ -23,6 +23,13 @@
23
23
  "import": "./src/app/index.ts"
24
24
  }
25
25
  },
26
+ "files": [
27
+ "dist",
28
+ "images",
29
+ "scss",
30
+ "src",
31
+ "package.json"
32
+ ],
26
33
  "repository": "https://github.com/ventoviro/windwalker-core",
27
34
  "author": "Simon Asika",
28
35
  "license": "MIT",
package/bin/release.js DELETED
@@ -1,47 +0,0 @@
1
- import minimist from 'minimist';
2
- import { execSync as exec } from 'child_process';
3
-
4
- const cliInput = minimist(process.argv.slice(2));
5
-
6
- const args = cliInput._;
7
-
8
- if (!args.length) {
9
- console.log('Please provide release type (major | minor | patch | premajor | preminor | prepatch | prerelease)');
10
- process.exit(255);
11
- }
12
-
13
- const help = `
14
- Usage: release.js -- <arguments for "npm version">
15
- -b Branch name to push.
16
- `;
17
-
18
- if (cliInput['help'] || cliInput['h']) {
19
- console.log(help);
20
- process.exit(0);
21
- }
22
-
23
- console.log(`>>> yarn build`);
24
- exec(`yarn build`, { stdio: 'inherit' });
25
-
26
- console.log(`>>> npm version ${args.join(' ')}`);
27
- const buffer = exec(`npm version ${args.join(' ')} --no-workspaces-update`);
28
-
29
- const ver = buffer.toString().split("\n")[1];
30
-
31
- console.log('>>> Git commit all');
32
- exec(`git add .`, { stdio: 'inherit' });
33
- try {
34
- exec(`git commit -am "Prepare release JS @windwalker-io/core ${ver}."`, { stdio: 'inherit' });
35
- } catch (e) {
36
- console.log(e.message);
37
- }
38
-
39
- const branch = cliInput['b'] || 'master';
40
-
41
- console.log('>>> Push to git');
42
-
43
- exec(`git push origin ${branch}`, { stdio: 'inherit' });
44
-
45
- console.log('>> Publish to npm');
46
-
47
- exec(`npm publish`, { stdio: 'inherit' });
package/core/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export function setupCounter(element: HTMLButtonElement): void
package/core/index.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/src/main.ts"></script>
12
- </body>
13
- </html>
package/core/lib/main.ts DELETED
@@ -1,9 +0,0 @@
1
- export function setupCounter(element: HTMLButtonElement) {
2
- let counter = 0
3
- const setCounter = (count: number) => {
4
- counter = count
5
- element.innerHTML = `count is ${counter}`
6
- }
7
- element.addEventListener('click', () => setCounter(++counter))
8
- setCounter(0)
9
- }
package/core/package.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "name": "core",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "files": [
7
- "dist",
8
- "index.d.ts"
9
- ],
10
- "main": "./dist/counter.umd.cjs",
11
- "module": "./dist/counter.js",
12
- "types": "./index.d.ts",
13
- "exports": {
14
- "types": "./index.d.ts",
15
- "import": "./dist/counter.js",
16
- "require": "./dist/counter.umd.cjs"
17
- },
18
- "scripts": {
19
- "dev": "vite",
20
- "build": "tsc && vite build"
21
- },
22
- "devDependencies": {
23
- "typescript": "~5.9.2",
24
- "vite": "^7.1.5"
25
- }
26
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/core/src/main.ts DELETED
@@ -1,23 +0,0 @@
1
- import './style.css'
2
- import typescriptLogo from './typescript.svg'
3
- import { setupCounter } from '../lib/main'
4
-
5
- document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
6
- <div>
7
- <a href="https://vite.dev" target="_blank">
8
- <img src="/vite.svg" class="logo" alt="Vite logo" />
9
- </a>
10
- <a href="https://www.typescriptlang.org/" target="_blank">
11
- <img src="${typescriptLogo}" class="logo vanilla" alt="TypeScript logo" />
12
- </a>
13
- <h1>Vite + TypeScript</h1>
14
- <div class="card">
15
- <button id="counter" type="button"></button>
16
- </div>
17
- <p class="read-the-docs">
18
- Click on the Vite and TypeScript logos to learn more
19
- </p>
20
- </div>
21
- `
22
-
23
- setupCounter(document.querySelector<HTMLButtonElement>('#counter')!)