@abcnews/aunty 17.0.0-next.4 → 17.0.0-next.6

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 (125) hide show
  1. package/CONTRIBUTING.md +19 -22
  2. package/README.md +37 -0
  3. package/TEMPLATES.md +112 -0
  4. package/dist/bin/aunty.js +1782 -0
  5. package/dist/bin/commander.js +1638 -0
  6. package/dist/lib/vite.js +133 -0
  7. package/dist/scripts/postinstall.d.ts +6 -0
  8. package/dist/src/bin/aunty.d.ts +9 -0
  9. package/dist/src/bin/commander.d.ts +5 -0
  10. package/dist/src/commands/build/index.d.ts +4 -0
  11. package/dist/src/commands/create/index.d.ts +4 -0
  12. package/dist/src/commands/create/types.d.ts +7 -0
  13. package/dist/src/commands/deploy/fs.d.ts +11 -0
  14. package/dist/src/commands/deploy/index.d.ts +12 -0
  15. package/dist/src/commands/migrate/index.d.ts +14 -0
  16. package/dist/src/commands/release/index.d.ts +8 -0
  17. package/dist/src/commands/release-check/git.d.ts +25 -0
  18. package/dist/src/commands/release-check/index.d.ts +9 -0
  19. package/dist/src/commands/serve/index.d.ts +4 -0
  20. package/dist/src/lib/constants.d.ts +3 -0
  21. package/dist/src/lib/ftp.d.ts +45 -0
  22. package/dist/src/lib/git.d.ts +29 -0
  23. package/dist/src/lib/initHelpers.d.ts +78 -0
  24. package/dist/src/lib/semver.d.ts +12 -0
  25. package/dist/src/lib/terminal.d.ts +14 -0
  26. package/dist/src/lib/util.d.ts +31 -0
  27. package/dist/src/lib/vite.d.ts +26 -0
  28. package/dist/src/types.d.ts +14 -0
  29. package/dist/templates/index.d.ts +8 -0
  30. package/dist/templates/svelte/base/init.d.ts +2 -0
  31. package/dist/templates/svelte/index.d.ts +2 -0
  32. package/dist/templates/svelte/patch-builder/init.d.ts +5 -0
  33. package/dist/templates/svelte/patch-js/init.d.ts +5 -0
  34. package/dist/templates/svelte/patch-odyssey/init.d.ts +2 -0
  35. package/dist/templates/svelte/patch-scrollyteller/init.d.ts +2 -0
  36. package/dist/templates/vanilla/base/init.d.ts +2 -0
  37. package/dist/templates/vanilla/index.d.ts +2 -0
  38. package/dist/templates/vanilla/patch-js/init.d.ts +5 -0
  39. package/eslint.config.mjs +6 -1
  40. package/package.json +27 -11
  41. package/src/bin/aunty.js +72 -0
  42. package/src/bin/aunty.ts +39 -52
  43. package/src/bin/commander.ts +174 -0
  44. package/src/commands/build/index.ts +23 -0
  45. package/src/commands/create/index.ts +148 -0
  46. package/src/commands/create/types.ts +7 -0
  47. package/src/commands/deploy/index.ts +40 -32
  48. package/src/commands/migrate/index.ts +320 -0
  49. package/src/commands/release/index.ts +127 -0
  50. package/src/commands/release-check/git.ts +14 -2
  51. package/src/commands/release-check/index.ts +139 -35
  52. package/src/commands/serve/index.ts +44 -0
  53. package/src/lib/colours.json +12 -0
  54. package/src/lib/constants.ts +3 -0
  55. package/src/{commands/deploy → lib}/ftp.ts +52 -23
  56. package/src/lib/git.ts +93 -0
  57. package/src/lib/initHelpers.ts +208 -0
  58. package/src/lib/semver.ts +50 -0
  59. package/src/lib/terminal.ts +85 -9
  60. package/src/lib/util.ts +66 -3
  61. package/src/lib/vite.ts +179 -0
  62. package/src/types.ts +16 -0
  63. package/templates/index.ts +11 -0
  64. package/templates/svelte/base/README.md +26 -0
  65. package/templates/svelte/base/contents/.editorconfig +12 -0
  66. package/templates/svelte/base/contents/.prettierrc +7 -0
  67. package/templates/svelte/base/contents/.vscode/extensions.json +3 -0
  68. package/templates/svelte/base/contents/LICENSE +21 -0
  69. package/templates/svelte/base/contents/README.md +16 -0
  70. package/templates/svelte/base/contents/_gitignore +24 -0
  71. package/templates/svelte/base/contents/index.html +22 -0
  72. package/templates/svelte/base/contents/package-lock.json +1373 -0
  73. package/templates/svelte/base/contents/package.json +29 -0
  74. package/templates/svelte/base/contents/src/App.svelte +21 -0
  75. package/templates/svelte/base/contents/src/assets/favicon.svg +4 -0
  76. package/templates/svelte/base/contents/src/components/Worm/Worm.svelte +59 -0
  77. package/templates/svelte/base/contents/src/components/Worm/worm.svg +4 -0
  78. package/templates/svelte/base/contents/src/iframe.ts +15 -0
  79. package/templates/svelte/base/contents/src/index.ts +26 -0
  80. package/templates/svelte/base/contents/svelte.config.js +2 -0
  81. package/templates/svelte/base/contents/tsconfig.app.json +22 -0
  82. package/templates/svelte/base/contents/tsconfig.json +7 -0
  83. package/templates/svelte/base/contents/tsconfig.node.json +28 -0
  84. package/templates/svelte/base/contents/vite-env.d.ts +7 -0
  85. package/templates/svelte/base/contents/vite.config.ts +40 -0
  86. package/templates/svelte/base/init.ts +39 -0
  87. package/templates/svelte/index.ts +52 -0
  88. package/templates/svelte/patch-builder/contents/builder/index.html +39 -0
  89. package/templates/svelte/patch-builder/contents/src/components/Builder/Builder.svelte +15 -0
  90. package/templates/svelte/patch-builder/init.ts +43 -0
  91. package/templates/svelte/patch-js/README.md +16 -0
  92. package/templates/svelte/patch-js/init.ts +61 -0
  93. package/templates/svelte/patch-odyssey/init.ts +10 -0
  94. package/templates/svelte/patch-scrollyteller/README.md +6 -0
  95. package/templates/svelte/patch-scrollyteller/contents/index.html +35 -0
  96. package/templates/svelte/patch-scrollyteller/contents/src/App.svelte +37 -0
  97. package/templates/svelte/patch-scrollyteller/contents/src/index.ts +36 -0
  98. package/templates/svelte/patch-scrollyteller/contents/src/types.ts +2 -0
  99. package/templates/svelte/patch-scrollyteller/init.ts +20 -0
  100. package/templates/vanilla/base/contents/LICENSE +21 -0
  101. package/templates/vanilla/base/contents/_gitignore +24 -0
  102. package/templates/vanilla/base/contents/index.html +22 -0
  103. package/templates/vanilla/base/contents/package-lock.json +999 -0
  104. package/templates/vanilla/base/contents/package.json +25 -0
  105. package/templates/vanilla/base/contents/public/favicon.svg +1 -0
  106. package/templates/vanilla/base/contents/public/icons.svg +24 -0
  107. package/templates/vanilla/base/contents/src/assets/hero.png +0 -0
  108. package/templates/vanilla/base/contents/src/assets/javascript.svg +1 -0
  109. package/templates/vanilla/base/contents/src/assets/vite.svg +1 -0
  110. package/templates/vanilla/base/contents/src/iframe.ts +17 -0
  111. package/templates/vanilla/base/contents/src/index.ts +17 -0
  112. package/templates/vanilla/base/contents/src/style.css +8 -0
  113. package/templates/vanilla/base/contents/tsconfig.app.json +23 -0
  114. package/templates/vanilla/base/contents/tsconfig.json +7 -0
  115. package/templates/vanilla/base/contents/tsconfig.node.json +28 -0
  116. package/templates/vanilla/base/contents/vite-env.d.ts +7 -0
  117. package/templates/vanilla/base/contents/vite.config.js +38 -0
  118. package/templates/vanilla/base/init.ts +33 -0
  119. package/templates/vanilla/index.ts +34 -0
  120. package/templates/vanilla/patch-js/README.md +0 -0
  121. package/templates/vanilla/patch-js/init.ts +27 -0
  122. package/test/helpers.ts +198 -0
  123. package/test/semver.test.ts +45 -0
  124. package/test/templates-e2e.test.ts +268 -0
  125. package/tsconfig.json +3 -1
package/CONTRIBUTING.md CHANGED
@@ -9,46 +9,43 @@ git clone git@github.com:abcnews/aunty.git
9
9
  ...then, from the project directory, run:
10
10
 
11
11
  ```bash
12
+ npm run build
12
13
  npm link
13
14
  ```
14
15
 
15
- This will link the globally-available `aunty` command to your clone.
16
-
17
- To revert to your original global install, run:
16
+ This will link the globally-available `aunty` command to your clone. While developing, run:
18
17
 
19
18
  ```bash
20
- npm unlink
19
+ npm run watch
21
20
  ```
22
21
 
23
- ## Releasing new versions of `@abcnews/aunty`
22
+ to compile changes to the `dist/` directory automatically.
24
23
 
25
- Releases are managed by `release-it`. To release a new version of aunty from the default branch, run:
24
+ To revert and uninstall the locally linked version, run:
26
25
 
27
- ```
28
- npm run release
26
+ ```bash
27
+ npm uninstall -g @abcnews/aunty
29
28
  ```
30
29
 
31
- By default this will do the following:
30
+ To reinstall the latest published registry version:
32
31
 
33
- 1. Bump the `patch` version in `package.json` (and `package-lock.json` if it exists)
34
- 2. Commit and tag that version.
35
- 3. Push the tag & commit to GitHub
36
- 4. Publish to npm
32
+ ```bash
33
+ npm install -g @abcnews/aunty
34
+ ```
37
35
 
38
- If you want to cut a minor or major release, run either of the following commands instead:
36
+ For ease of use, you can use the Aunty version directly with `node <path to aunty repo>/dist/bin/aunty.js -h`.
39
37
 
40
- ```
41
- npm run release -- minor
42
- npm run release -- major
43
- ```
38
+ ## Releasing new versions of `@abcnews/aunty`
44
39
 
45
- If you're ever unsure about what will happen, you can perform a dry run (which logs to the console) by running:
40
+ Releases are managed by `np`. To release a new version of aunty from the default branch, run:
46
41
 
42
+ ```bash
43
+ npm run release
47
44
  ```
48
- npm run release -- --dry-run
49
- ```
50
45
 
51
- View the [`release-it` docs](https://www.npmjs.com/package/release-it) for full usage examples, including pre-release and npm tag management.
46
+ This will run tests, prompt you to select the version increment, and then publish to npm, commit, tag, and push to GitHub.
47
+
48
+ For more information, see the [`np` documentation](https://github.com/sindresorhus/np).
52
49
 
53
50
  ## Style
54
51
 
package/README.md CHANGED
@@ -3,3 +3,40 @@
3
3
  A toolkit for working with ABC News projects
4
4
 
5
5
  THIS IS A NEW BRANCH FOR AUNTY@NEXT PLEASE BITE OFF A CHUNK OF WORK AND MERGE INTO the `aunty-next` BRANCH
6
+
7
+ # Contributing
8
+
9
+ The repo is split up by commands. You should be able to jump into the command you're interested in, and follow the logic from start to finish.
10
+
11
+ ### Command Entry Points
12
+
13
+ - [build](./src/commands/build/index.ts)
14
+ - [create](./src/commands/create/index.ts) (aliased as `new`)
15
+ - [deploy](./src/commands/deploy/index.ts)
16
+ - [release](./src/commands/release/index.ts)
17
+ - [release-check](./src/commands/release-check/index.ts)
18
+ - [serve](./src/commands/serve/index.ts)
19
+
20
+ Aunty uses the pattern of "helpers" to abstract complex logic out and hopefully make our main entrypoints flat and readable.
21
+
22
+ The main CLI logic is in [src/bin/commander.ts](./src/bin/commander.ts).
23
+
24
+ # Developing
25
+
26
+ To develop on Aunty, run the watch command to compile your changes in real-time:
27
+
28
+ ```bash
29
+ npm run watch
30
+ ```
31
+
32
+ Or build the project manually:
33
+
34
+ ```bash
35
+ npm run build
36
+ ```
37
+
38
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for specifics.
39
+
40
+ # Templates
41
+
42
+ `aunty create` uses a custom template system to create new projects. See [TEMPLATES.md](./TEMPLATES.md) for specifics.
package/TEMPLATES.md ADDED
@@ -0,0 +1,112 @@
1
+ `aunty create` uses a custom template system to create new projects. Templates have three main components:
2
+
3
+ 1. a programmatic index that uses clack prompts to ask for desired configuration
4
+ 2. a base template containing the dir to copy from + a programmatic script to perform the copy and any other tweaks
5
+ 3. a series of "patches" containing programmatic scripts to copy over additional files or make changes to the base template.
6
+
7
+ The intention is to make this followable in logic, so you don't need any prior knowledge to make a new template. Hopefully this is helpful.
8
+
9
+ ## Guide to making a new template
10
+
11
+ The following steps will guide you through creating a new template from scratch.
12
+
13
+ ### 1. Scaffold your starting point
14
+
15
+ It's usually easier to start with a working scaffold than writing a project framework from scratch.
16
+
17
+ 1. Generate your base project in a temporary folder using standard initialization tools (e.g., `npm create vite@latest`).
18
+ 2. Test the generated project to ensure it works as expected before converting it into a template.
19
+
20
+ ### 2. Create the Base Template
21
+
22
+ Now you need to bring those scaffolded files into the Aunty project.
23
+
24
+ 1. Create the directory structure for your template's base contents: `templates/<your-template>/base/contents`.
25
+ 2. Copy your scaffolded project files into this `contents/` directory.
26
+ 3. **Rename `.gitignore` to `_gitignore`**.
27
+
28
+ **Note:** NPM drops `.gitignore` files by default during package publishing. If you don't rename it, the file won't be included when Aunty is installed. Aunty's initialization helper will automatically rename it back to `.gitignore` when a user creates a new project.
29
+
30
+ ### 3. Create the Base Init Script
31
+
32
+ Next, you need a script to copy those base files to the user's destination directory.
33
+
34
+ 1. Create `templates/<your-template>/base/init.ts`.
35
+ 2. Export an `init(options: InitOptions)` function.
36
+ 3. Use the built-in helper functions (from [`src/lib/initHelpers.ts`](./src/lib/initHelpers.ts)) to copy the contents and install Aunty as a dependency.
37
+
38
+ ```typescript
39
+ import path from "node:path";
40
+ import { copyContents, installAunty } from "../../../src/lib/initHelpers.ts";
41
+ import type { InitOptions } from "../../../src/commands/create/types.ts";
42
+
43
+ export async function init(options: InitOptions) {
44
+ // Copy the files from base/contents to the new project directory
45
+ await copyContents(path.join(import.meta.dirname, "contents"), options.dir);
46
+
47
+ // Ensure @abcnews/aunty is added to the devDependencies
48
+ await installAunty(options.dir);
49
+ }
50
+ ```
51
+
52
+ ### 4. Create the Main Entry Point
53
+
54
+ The entry point handles the user flow, asking any required questions before calling the init script.
55
+
56
+ 1. Create `templates/<your-template>/index.ts`.
57
+ 2. Export a default `run(options: InitOptions)` function.
58
+ 3. Use [`@clack/prompts`](https://github.com/natemoo-re/clack/tree/main/packages/prompts) to gather user preferences (e.g., confirm if they want TypeScript, or select a variant).
59
+ 4. Invoke your base `init.ts` script.
60
+
61
+ ```typescript
62
+ import { confirm, isCancel, cancel } from "@clack/prompts";
63
+ import type { InitOptions } from "../../src/commands/create/types.ts";
64
+ import { init as baseInit } from "./base/init.ts";
65
+ import { init as jsInit } from "./patch-js/init.ts";
66
+
67
+ export default async function run(options: InitOptions) {
68
+ const useTypescript = await confirm({
69
+ message: "Do you want to use TypeScript?",
70
+ initialValue: true,
71
+ });
72
+
73
+ if (isCancel(useTypescript)) {
74
+ cancel("Operation cancelled.");
75
+ return 1;
76
+ }
77
+
78
+ // 1. Run the base setup first
79
+ await baseInit(options);
80
+
81
+ // 2. Apply patches conditionally based on user answers
82
+ if (!useTypescript) {
83
+ await jsInit(options);
84
+ }
85
+
86
+ return 0;
87
+ }
88
+ ```
89
+
90
+ ### 5. Create Patches (Optional)
91
+
92
+ If your template requires variants (e.g., an Odyssey version vs a standard version, or JS vs TS), you can create "patches".
93
+
94
+ 1. Create a patch directory (e.g., `templates/<your-template>/patch-js/contents` and `templates/<your-template>/patch-js/init.ts`).
95
+ 2. Patches are just smaller init scripts that layer extra files, string replacements, or `package.json` edits on top of the base template.
96
+ 3. Invoke the patch's `init` function in your main `index.ts` conditionally, as demonstrated in the snippet in Step 4.
97
+
98
+ ### 6. Test Locally
99
+
100
+ While developing your new template, you can test it locally by running the CLI from the root of the Aunty repository:
101
+
102
+ ```bash
103
+ node . create
104
+ ```
105
+
106
+ or, in another dir with
107
+
108
+ ```bash
109
+ node ../aunty create
110
+ ```
111
+
112
+ This will invoke your local version of Aunty, allowing you to test the prompt flow and verify the generated output in your chosen destination directory.