akanjs 2.0.3 → 2.0.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/cli/index.js CHANGED
@@ -865,7 +865,7 @@ import {
865
865
  spawn
866
866
  } from "child_process";
867
867
  import { readFileSync as readFileSync3 } from "fs";
868
- import { mkdir as mkdir2, readdir as readDirEntries, stat as stat2 } from "fs/promises";
868
+ import { copyFile, mkdir as mkdir2, readdir as readDirEntries, stat as stat2 } from "fs/promises";
869
869
  import path7 from "path";
870
870
  var {$ } = globalThis.Bun;
871
871
  import chalk4 from "chalk";
@@ -2294,6 +2294,39 @@ ${summary.join(", ")} found${output.join(`
2294
2294
  }
2295
2295
  }
2296
2296
 
2297
+ var staticTemplateFileExtensions = new Set([
2298
+ ".avif",
2299
+ ".bmp",
2300
+ ".cjs",
2301
+ ".css",
2302
+ ".eot",
2303
+ ".gif",
2304
+ ".html",
2305
+ ".ico",
2306
+ ".jpeg",
2307
+ ".jpg",
2308
+ ".js",
2309
+ ".json",
2310
+ ".map",
2311
+ ".md",
2312
+ ".mjs",
2313
+ ".mp3",
2314
+ ".mp4",
2315
+ ".ogg",
2316
+ ".otf",
2317
+ ".pdf",
2318
+ ".png",
2319
+ ".svg",
2320
+ ".ttf",
2321
+ ".txt",
2322
+ ".wasm",
2323
+ ".wav",
2324
+ ".webm",
2325
+ ".webp",
2326
+ ".woff",
2327
+ ".woff2",
2328
+ ".xml"
2329
+ ]);
2297
2330
  var execEmoji = {
2298
2331
  workspace: "\uD83C\uDFE0",
2299
2332
  app: "\uD83D\uDE80",
@@ -2689,6 +2722,15 @@ class Executor {
2689
2722
  const convertedContent = Object.entries(dict).reduce((data, [key, value]) => data.replace(new RegExp(`<%= ${key} %>`, "g"), value), content);
2690
2723
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2691
2724
  return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
2725
+ } else if (staticTemplateFileExtensions.has(path7.extname(targetPath).toLowerCase())) {
2726
+ const convertedTargetPath = Object.entries(dict).reduce((path8, [key, value]) => path8.replace(new RegExp(`__${key}__`, "g"), value), targetPath);
2727
+ const writePath = this.getPath(convertedTargetPath);
2728
+ const dirname3 = path7.dirname(writePath);
2729
+ if (!await FileSys.dirExists(dirname3))
2730
+ await mkdir2(dirname3, { recursive: true });
2731
+ await copyFile(templatePath, writePath);
2732
+ this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2733
+ return { filePath: writePath, content: "" };
2692
2734
  } else
2693
2735
  return null;
2694
2736
  }
@@ -8,7 +8,7 @@ import {
8
8
  spawn,
9
9
  } from "node:child_process";
10
10
  import { readFileSync } from "node:fs";
11
- import { mkdir, readdir as readDirEntries, stat } from "node:fs/promises";
11
+ import { copyFile, mkdir, readdir as readDirEntries, stat } from "node:fs/promises";
12
12
  import path from "node:path";
13
13
  import {
14
14
  capitalize,
@@ -30,6 +30,40 @@ import { Spinner } from "./spinner";
30
30
  import { TypeChecker } from "./typeChecker";
31
31
  import type { FileContent, PackageJson, TsConfigJson } from "./types";
32
32
 
33
+ const staticTemplateFileExtensions = new Set([
34
+ ".avif",
35
+ ".bmp",
36
+ ".cjs",
37
+ ".css",
38
+ ".eot",
39
+ ".gif",
40
+ ".html",
41
+ ".ico",
42
+ ".jpeg",
43
+ ".jpg",
44
+ ".js",
45
+ ".json",
46
+ ".map",
47
+ ".md",
48
+ ".mjs",
49
+ ".mp3",
50
+ ".mp4",
51
+ ".ogg",
52
+ ".otf",
53
+ ".pdf",
54
+ ".png",
55
+ ".svg",
56
+ ".ttf",
57
+ ".txt",
58
+ ".wasm",
59
+ ".wav",
60
+ ".webm",
61
+ ".webp",
62
+ ".woff",
63
+ ".woff2",
64
+ ".xml",
65
+ ]);
66
+
33
67
  export const execEmoji = {
34
68
  workspace: "🏠",
35
69
  app: "🚀",
@@ -451,6 +485,17 @@ export class Executor {
451
485
  );
452
486
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
453
487
  return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
488
+ } else if (staticTemplateFileExtensions.has(path.extname(targetPath).toLowerCase())) {
489
+ const convertedTargetPath = Object.entries(dict).reduce(
490
+ (path, [key, value]) => path.replace(new RegExp(`__${key}__`, "g"), value),
491
+ targetPath,
492
+ );
493
+ const writePath = this.getPath(convertedTargetPath);
494
+ const dirname = path.dirname(writePath);
495
+ if (!(await FileSys.dirExists(dirname))) await mkdir(dirname, { recursive: true });
496
+ await copyFile(templatePath, writePath);
497
+ this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
498
+ return { filePath: writePath, content: "" };
454
499
  } else return null;
455
500
  }
456
501
  async _applyTemplate({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "bin": {