create-lt-adventure 0.0.16 → 0.1.3

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.
Files changed (36) hide show
  1. package/README.md +85 -85
  2. package/addons/github-workflow/addon.json +5 -5
  3. package/addons/github-workflow/main.yml +96 -48
  4. package/addons/github-workflow/{setup.ts → setup.mjs} +115 -112
  5. package/addons/sf2e-pf2e-redirects/addon.json +5 -0
  6. package/addons/sf2e-pf2e-redirects/setup.mjs +119 -0
  7. package/dist/bin.js +223 -84
  8. package/dist/bin.js.map +1 -1
  9. package/dist/migrate.d.ts +2 -0
  10. package/dist/migrate.d.ts.map +1 -0
  11. package/dist/migrate.js +169 -0
  12. package/dist/migrate.js.map +1 -0
  13. package/dist/options.d.ts +5 -2
  14. package/dist/options.d.ts.map +1 -1
  15. package/dist/options.js +14 -5
  16. package/dist/options.js.map +1 -1
  17. package/package.json +68 -66
  18. package/templates/vite/.env.example +1 -1
  19. package/templates/vite/CHANGELOG +1 -0
  20. package/templates/vite/gitignore +37 -37
  21. package/templates/vite/module.json +37 -36
  22. package/templates/vite/package.json +3 -2
  23. package/templates/vite/scripts/extractPacks.mjs +54 -49
  24. package/templates/vite/scripts/jsonReplacer.mjs +11 -0
  25. package/templates/vite/scripts/onCreate.mjs +41 -13
  26. package/templates/vite/scripts/symlink.mjs +78 -78
  27. package/templates/vite/src/adventureSheet/index.js +497 -497
  28. package/templates/vite/src/hooks.ts +22 -0
  29. package/templates/vite/src/index.js +4 -4
  30. package/templates/vite/src/lib/utils.ts +1 -0
  31. package/templates/vite/src/misc/prosemirror.js +46 -46
  32. package/templates/vite/src/module.css +306 -306
  33. package/templates/vite/src/types.d.ts +7 -7
  34. package/templates/vite/tsconfig.json +33 -29
  35. package/templates/vite/vite.config.ts +129 -128
  36. package/templates/vite/bun.lock +0 -802
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A replacer function or an array of property names in the object to include in the resulting string.
3
+ * https://github.com/foundryvtt/foundryvtt-cli
4
+ * @param {string} key
5
+ * @param {any} value
6
+ * @returns {any|Array<string|number>}
7
+ */
8
+ export function replacer(key, value) {
9
+ // Modify this to your liking.
10
+ return value;
11
+ }
@@ -1,27 +1,55 @@
1
- import { renameSync } from "fs";
1
+ import { renameSync, readFileSync, writeFileSync, unlinkSync, existsSync } from "fs";
2
2
 
3
- const mod = (await Bun.file("../module.json").json());
4
- const pack = (await Bun.file("../package.json").json());
3
+ const mod = JSON.parse(readFileSync("../module.json", "utf8"));
4
+ const pack = JSON.parse(readFileSync("../package.json", "utf8"));
5
+ const css = readFileSync("../src/module.css", "utf8");
5
6
 
6
- // Module
7
- mod.esmodules = [`dist/${mod.id}.js`];
8
- mod.styles = [`dist/${mod.id}.css`];
7
+ // CSS
8
+ const updatedCss = css.replaceAll("module-template", mod.id);
9
9
 
10
10
  // Package
11
11
  pack.name = mod.id;
12
12
 
13
+ // Module
14
+ mod.esmodules = [`dist/${mod.id}.js`];
15
+ mod.styles = [`dist/${mod.id}.css`];
13
16
  mod.media = [
14
17
  {
15
- "auto": true,
16
18
  "type": "setup",
17
- "url": `modules/${mod.id}/assets/setup.webp`
19
+ "url": `modules/${mod.id}/assets/setup.webp`,
20
+ "thumbnail": `modules/${mod.id}/assets/setup.webp`
18
21
  }
19
22
  ];
20
23
 
21
- await Bun.write("../module.json", JSON.stringify(mod, null, "\t"));
22
- await Bun.write("../package.json", JSON.stringify(pack, null, "\t"));
24
+ // Final writes and global renames
23
25
 
24
- // Rename gitignore to .gitignore
25
- renameSync("../gitignore", "../.gitignore");
26
+ const modString = JSON.stringify(mod, null, "\t")
27
+ // .replaceAll("AUTHOR", data.author)
28
+ .replaceAll("REPO", mod.id);
29
+
30
+ const packString = JSON.stringify(pack, null, "\t")
31
+ // .replaceAll("AUTHOR", data.author)
32
+ .replaceAll("REPO", mod.id);
33
+
34
+ writeFileSync("../module.json", modString);
35
+ writeFileSync("../package.json", packString);
36
+ writeFileSync("../src/module.css", updatedCss);
26
37
 
27
- export { };
38
+ // Rename gitignore to .gitignore
39
+ try {
40
+ renameSync("../gitignore", "../.gitignore");
41
+ } catch (err) {
42
+ // EEXIST means .gitignore already exists - delete gitignore and move on
43
+ // ENOENT means gitignore was already renamed - also fine
44
+ if (err.code !== "EEXIST" && err.code !== "ENOENT") {
45
+ throw err;
46
+ }
47
+ // Clean up the non-canonical name if it somehow still exists
48
+ if (existsSync("../gitignore")) {
49
+ try {
50
+ unlinkSync("../gitignore");
51
+ } catch {
52
+ // Already gone or doesn't exist - fine
53
+ }
54
+ }
55
+ }
@@ -1,79 +1,79 @@
1
- import { lstatSync, rmSync, symlinkSync, unlinkSync, readFileSync, writeFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { homedir } from "node:os";
4
- import process from "node:process";
5
- import * as p from "@clack/prompts";
6
- import moduleJSON from "../module.json" with { type: "json" };
7
- import { yellow } from "kolorist";
8
-
9
- p.intro(`${moduleJSON.id} symlink script`)
10
-
11
- // Store config in user's home directory
12
- const configPath = resolve(homedir(), ".foundry-symlink-config.json");
13
-
14
- // Load last known path from config
15
- let lastPath = null;
16
- try {
17
- const config = JSON.parse(readFileSync(configPath, "utf-8"));
18
- lastPath = config.dataPath;
19
- } catch {
20
- // Config doesn't exist yet, that's fine
21
- }
22
-
23
- const windowsInstructions = process.platform === "win32" ? " Start with a drive letter (\"C:\\\")." : "";
24
- const lastFolder = lastPath ? `(last: ${lastPath})` : "";
25
- const promptPath = await p.text({
26
- message: `Enter the full path to your Foundry data folder.${windowsInstructions}`,
27
- placeholder: lastPath,
28
- initialValue: lastPath,
29
- validate(val) {
30
- const value = val.replace(/\W*$/, "").trim();
31
- if (!value || !/\bData$/.test(value)) {
32
- return (`"${value}" does not contain ${yellow('/Data')}`);
33
- }
34
- }
35
- });
36
-
37
- let dataPath = promptPath.replace(/\W*$/, "").trim();
38
-
39
- if (dataPath !== lastPath) {
40
- // Ask if user wants to save the path
41
- const shouldSave = await p.confirm({
42
- initialValue: true,
43
- message: `Save "${dataPath}" for future use?`,
44
- });
45
-
46
- if (shouldSave) {
47
- writeFileSync(configPath, JSON.stringify({ dataPath }, null, 2));
48
- }
49
- }
50
-
51
- const symlinkPath = resolve(dataPath, "modules", moduleJSON.id);
52
- const symlinkStats = lstatSync(symlinkPath, { throwIfNoEntry: false });
53
- if (symlinkStats) {
54
- const atPath = symlinkStats.isDirectory() ? "folder" : symlinkStats.isSymbolicLink() ? "symlink" : "file";
55
- const proceed = await p.confirm({
56
- initialValue: false,
57
- message: `A "${moduleJSON.id}" ${atPath} already exists in the "modules" subfolder. Replace with new symlink?`,
58
- });
59
- if (!proceed) {
60
- p.cancel("Aborting.");
61
- process.exit(0);
62
- }
63
- }
64
-
65
- try {
66
- if (symlinkStats?.isDirectory()) {
67
- rmSync(symlinkPath, { recursive: true, force: true });
68
- } else if (symlinkStats) {
69
- unlinkSync(symlinkPath);
70
- }
71
- symlinkSync(resolve(process.cwd()), symlinkPath);
72
- } catch (error) {
73
- if (error instanceof Error) {
74
- console.error(`An error was encountered trying to create a symlink: ${error.message}`);
75
- process.exit(1);
76
- }
77
- }
78
-
1
+ import { lstatSync, rmSync, symlinkSync, unlinkSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { homedir } from "node:os";
4
+ import process from "node:process";
5
+ import * as p from "@clack/prompts";
6
+ import moduleJSON from "../module.json" with { type: "json" };
7
+ import { yellow } from "kolorist";
8
+
9
+ p.intro(`${moduleJSON.id} symlink script`)
10
+
11
+ // Store config in user's home directory
12
+ const configPath = resolve(homedir(), ".foundry-symlink-config.json");
13
+
14
+ // Load last known path from config
15
+ let lastPath = null;
16
+ try {
17
+ const config = JSON.parse(readFileSync(configPath, "utf-8"));
18
+ lastPath = config.dataPath;
19
+ } catch {
20
+ // Config doesn't exist yet, that's fine
21
+ }
22
+
23
+ const windowsInstructions = process.platform === "win32" ? " Start with a drive letter (\"C:\\\")." : "";
24
+ const lastFolder = lastPath ? `(last: ${lastPath})` : "";
25
+ const promptPath = await p.text({
26
+ message: `Enter the full path to your Foundry data folder.${windowsInstructions}`,
27
+ placeholder: lastPath,
28
+ initialValue: lastPath,
29
+ validate(val) {
30
+ const value = val.replace(/\W*$/, "").trim();
31
+ if (!value || !/\bData$/.test(value)) {
32
+ return (`"${value}" does not contain ${yellow('/Data')}`);
33
+ }
34
+ }
35
+ });
36
+
37
+ let dataPath = promptPath.replace(/\W*$/, "").trim();
38
+
39
+ if (dataPath !== lastPath) {
40
+ // Ask if user wants to save the path
41
+ const shouldSave = await p.confirm({
42
+ initialValue: true,
43
+ message: `Save "${dataPath}" for future use?`,
44
+ });
45
+
46
+ if (shouldSave) {
47
+ writeFileSync(configPath, JSON.stringify({ dataPath }, null, 2));
48
+ }
49
+ }
50
+
51
+ const symlinkPath = resolve(dataPath, "modules", moduleJSON.id);
52
+ const symlinkStats = lstatSync(symlinkPath, { throwIfNoEntry: false });
53
+ if (symlinkStats) {
54
+ const atPath = symlinkStats.isDirectory() ? "folder" : symlinkStats.isSymbolicLink() ? "symlink" : "file";
55
+ const proceed = await p.confirm({
56
+ initialValue: false,
57
+ message: `A "${moduleJSON.id}" ${atPath} already exists in the "modules" subfolder. Replace with new symlink?`,
58
+ });
59
+ if (!proceed) {
60
+ p.cancel("Aborting.");
61
+ process.exit(0);
62
+ }
63
+ }
64
+
65
+ try {
66
+ if (symlinkStats?.isDirectory()) {
67
+ rmSync(symlinkPath, { recursive: true, force: true });
68
+ } else if (symlinkStats) {
69
+ unlinkSync(symlinkPath);
70
+ }
71
+ symlinkSync(resolve(process.cwd()), symlinkPath);
72
+ } catch (error) {
73
+ if (error instanceof Error) {
74
+ console.error(`An error was encountered trying to create a symlink: ${error.message}`);
75
+ process.exit(1);
76
+ }
77
+ }
78
+
79
79
  p.outro(`Symlink successfully created at "${symlinkPath}"!`);