Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ CLI rewrite #178

Merged
merged 146 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
81a5f8e
Merge pull request #2 from QwikDev/main
siguici Oct 15, 2024
94c87f6
:recycle: Use a utils module for the CLI
siguici Oct 15, 2024
70a3f97
:technologist: Improve CLI configuration
siguici Oct 15, 2024
0bc307b
:technologist: Use CLI default options
siguici Oct 15, 2024
b50de1d
:technologist: Improve usage examples
siguici Oct 15, 2024
6dbb067
:memo: Update CLI documentation
siguici Oct 15, 2024
2d9a535
:package: Export CLI utils
siguici Oct 15, 2024
aea8ced
:technologist: Use CLI arguments in the execution file
siguici Oct 16, 2024
7b125d5
:label: Fix the adapter type
siguici Oct 16, 2024
df67909
:sparkles: Add helpers to validate inputs
siguici Oct 16, 2024
e563933
:label: Use `asserts` to validate inputs
siguici Oct 16, 2024
dc88b12
:technologist: Extend input validation
siguici Oct 16, 2024
37caa1c
:technologist: Extend validation of `number` and `string` inputs
siguici Oct 16, 2024
e34112e
:recycle: Modulate input scanning
siguici Oct 16, 2024
e9e9a55
:recycle: Improve scanning of other inputs
siguici Oct 16, 2024
8b66c7f
:sparkles: Use an app to make it easier to execute commands
siguici Oct 16, 2024
fa3cf50
:recycle: Refactor the application's `run` method
siguici Oct 16, 2024
942a150
:rotating_light: Fix code lint
siguici Oct 16, 2024
f52f24b
:technologist: Parse raw command line arguments
siguici Oct 17, 2024
9a7d2c6
:technologist: Use `undefined` as default value for options
siguici Oct 17, 2024
f51022c
:pencil2: Rename `installDependencies` to `$pmInstall`
siguici Oct 17, 2024
be330e4
:hammer: Add package manager `exec` and `dlx` commands
siguici Oct 17, 2024
69748a8
:rotating_light: Fix code lint
siguici Oct 18, 2024
08d7b14
:technologist: Make the project name optional
siguici Oct 18, 2024
4336765
:heavy_plus_sign: Add Vitest and @qwikdev/create-astro
siguici Oct 19, 2024
606345b
:wrench: Setup vitest
siguici Oct 20, 2024
0e7225d
:technologist: Run reports concurrently
siguici Oct 20, 2024
9278f0d
:sparkles: Allow user to add `@qwikdev/astro` to an existing project
siguici Oct 20, 2024
34c4fe0
:monocle_face: Display the package manager error
siguici Oct 20, 2024
c18b8fc
:bug: Fix execution of packages manager commands
siguici Oct 20, 2024
9663a6a
:arrow_up: Update dependencies
siguici Dec 4, 2024
76d792f
:fire: Delete unused import
siguici Dec 4, 2024
fad2eea
:construction: Add command class
siguici Dec 8, 2024
1222d31
:construction: Add commands to the application class
siguici Dec 8, 2024
cff0266
:construction: Parse commands from the application
siguici Dec 8, 2024
13a7ba5
:construction: Move `cmd.ts` content to `app.ts`
siguici Dec 8, 2024
c08f657
:bug: Fix application execution
siguici Dec 8, 2024
4680d02
:bulb: Improve JSDoc
siguici Dec 8, 2024
ff240f2
🔀 Merge `main` from @QwikDev / astro
siguici Dec 8, 2024
821cf2e
:technologist: Allow use of certain flags on all commands
siguici Dec 8, 2024
c9bab83
:bug: Fix use of `run`, `exec` and `dlx` in subprocesses
siguici Dec 8, 2024
9f44566
:truck: Rename `app` to `core`
siguici Dec 8, 2024
0bcb552
:recycle: Instantiate the application from the index file
siguici Dec 8, 2024
9ff5698
:recycle: Extract everything application specific from the core
siguici Dec 8, 2024
85e6924
:technologist: Fix `yes` and `no` conflicts
siguici Dec 8, 2024
79c8468
:truck: Rename `BaseApplication` to `Program`
siguici Dec 8, 2024
92fbab2
:recycle: Move the application definition to `app.ts`
siguici Dec 8, 2024
60e5c82
:technologist: Encapsuler inputs/outputs in the program
siguici Dec 8, 2024
ec95dbc
:beers: Chore(#167): update Astro config to use consistent `qwikdev` …
siguici Dec 9, 2024
88985dd
:arrow_up: Upgrade dependencies
siguici Dec 9, 2024
263632f
:coffin: Remove dead code
siguici Dec 9, 2024
60286b4
:rotating_light: Migrate Biome and format code
siguici Dec 9, 2024
a1e2f19
:bug: Fix default values of global flags
siguici Dec 9, 2024
330dac4
:bug: Fix spawn execution issue (#167) on Windows by using `which` to…
siguici Dec 9, 2024
640d841
:adhesive_bandage: Fix #166: Preserve hidden files (e.g. .gitignore) …
siguici Dec 9, 2024
00a9da6
:pencil2: Rename `Program.parseArgs` to `Program.parse`
siguici Dec 9, 2024
e042b5a
:recycle: Put inputs/outputs in console file
siguici Dec 9, 2024
b6e355c
:recycle: Move everything related to processes and subprocesses into …
siguici Dec 9, 2024
4500c74
:test_tube: Prepare for testing
siguici Dec 10, 2024
a65fd1b
:arrow_up: Update dependencies
siguici Dec 10, 2024
6f5ea9f
:label: Configure the type of arguments parsed from the program
siguici Dec 10, 2024
df1246e
:sparkles: Add programmatic interaction execution
siguici Dec 14, 2024
52a3282
:zap: Improve interactive execution
siguici Dec 14, 2024
d0167c7
:mag: Check prompts in buffer instead of chunk
siguici Dec 14, 2024
c18572f
:alembic: Clean ANSI sequences from the buffer
siguici Dec 14, 2024
e9087c5
:recycle: Improve finishing and error handling of interactive executions
siguici Dec 14, 2024
2c22b55
:heavy_plus_sign: Use `cross-spawn`
siguici Dec 15, 2024
35882ac
:package: Fix package entrypoints
siguici Dec 15, 2024
2d69b2e
:heavy_plus_sign: Use `node-pty`
siguici Dec 15, 2024
5e548f9
:recycle: Move interactive executions to the `pty` module
siguici Dec 15, 2024
339bfcc
:heavy_plus_sign: Use `strip-ansi`
siguici Dec 15, 2024
1e6bc79
🔀 Merge `main` from @QwikDev / astro
siguici Dec 15, 2024
4ce845f
:recycle: Improve `pty` executions
siguici Dec 15, 2024
e7d06ec
:technologist: Add `Ctrl+C`/ `Ctrl+D` type inputs
siguici Dec 15, 2024
fe91e34
:zap: Add timeout
siguici Dec 15, 2024
e02aa31
:label: Use ESM format from `fs-extra`
siguici Dec 15, 2024
7860ec2
:alembic: Use `tsm` through Node.js to enable source maps
siguici Dec 15, 2024
d2bfab6
:arrow_up: Update dependencies
siguici Dec 15, 2024
c713fd5
:hammer: Add CLI build into build script
siguici Dec 15, 2024
14584d8
:technologist: Use the application name as script name
siguici Dec 15, 2024
9bd59a2
:building_construction: Improve the program live circle
siguici Dec 15, 2024
f36d22d
:recycle: Improve the program definition
siguici Dec 15, 2024
bfd8603
:label: Remove requirement from definitions
siguici Dec 15, 2024
8f73f03
:technologist: Allow to intercept a prompt by providing an input
siguici Dec 16, 2024
988da83
:sparkles: Allow user to add QwikDev/astro to an existing project
siguici Dec 16, 2024
28a0096
:children_crossing: Ask to add or force in interactive mode
siguici Dec 16, 2024
b42e5b9
:children_crossing: Use existing package name as default
siguici Dec 16, 2024
1ceaa1b
:white_check_mark: Test the default definition
siguici Dec 19, 2024
98bdf79
:white_check_mark: Test arguments and options
siguici Dec 19, 2024
805032c
:art: Improve test groups
siguici Dec 19, 2024
54b50d3
:white_check_mark: Test the negation of options
siguici Dec 19, 2024
bf68ddf
:white_check_mark: Test option aliases
siguici Dec 19, 2024
5d5f0d8
:green_heart: Update dependencies and use CLI tests instead of root t…
siguici Dec 19, 2024
ce3783f
:coffin: Remove unnecessary files and dependencies
siguici Dec 19, 2024
9ec3a74
:white_check_mark: Start testing interactions
siguici Dec 20, 2024
a7684f2
:white_check_mark: Test interactions performed before execution
siguici Dec 20, 2024
b93a6eb
:white_check_mark: Test the adapter and use `none` as default
siguici Dec 20, 2024
92d1436
:mute: Remove debug log
siguici Dec 20, 2024
e4bfceb
:zap: Ignore execution prompts
siguici Dec 20, 2024
9a3dc03
:label: Fix scanned input types
siguici Dec 21, 2024
bb4ce20
:label: Improve scanned input types
siguici Dec 21, 2024
4426e1c
:bug: Fix creating project
siguici Dec 21, 2024
be61d08
:white_check_mark: Update CLI unit test
siguici Dec 21, 2024
1db1375
:label: Remove const type definition
siguici Dec 21, 2024
4c34ff4
:white_check_mark: Test the application execution
siguici Dec 21, 2024
0bbd309
:test_tube: Prepare to test the application execution
siguici Dec 21, 2024
4cd54f6
:package: Add utils as entry
siguici Dec 21, 2024
4acff54
:pencil2: Import `afterEach` from `Vitest` instead of `Node`
siguici Dec 21, 2024
a79b7a0
:white_check_mark: Test generated files using Japa instead of Vitest
siguici Dec 22, 2024
be25c92
:heavy_minus_sign: Remove Vitest
siguici Dec 22, 2024
7282123
:coffin: Remove unsed imports
siguici Dec 22, 2024
c6a11e5
:white_check_mark: Test ESLint & Prettier files
siguici Dec 22, 2024
63b4aa9
:recycle: Group default generated files
siguici Dec 22, 2024
20ccd71
:recycle: Improve getting generated files
siguici Dec 22, 2024
4f72e5e
:technologist: Use path tester macro
siguici Dec 22, 2024
b0d793c
:white_check_mark: Test generated directories
siguici Dec 22, 2024
d610c43
:package: Improve the index file modules
siguici Dec 22, 2024
709b892
:green_heart: Test the built package instead of sources
siguici Dec 22, 2024
9ac1d13
:white_check_mark: Test the application name and version
siguici Dec 22, 2024
ea2050c
:recycle: Improve tests structure
siguici Dec 22, 2024
0085712
:bug: Fix project name
siguici Dec 22, 2024
b06f453
:white_check_mark: Fix interaction tests
siguici Dec 22, 2024
d0a8fdf
:white_check_mark: Fix destination interaction test
siguici Dec 22, 2024
e95a274
:art: Improve interaction group
siguici Dec 22, 2024
bb2c495
:art: Improve tests structure
siguici Dec 23, 2024
4bb64eb
:recycle: Perform all interactions before program execution
siguici Dec 23, 2024
78f4b55
:bug: Fix yes and no options
siguici Dec 24, 2024
9c3a36d
:adhesive_bandage: Add conflicts between `add` and `force` options
siguici Dec 24, 2024
3c1f072
:arrow_up: Update dependencies
siguici Dec 24, 2024
bb949f2
:alembic: Disable tests timeout
siguici Dec 24, 2024
3d4589a
:recycle: Remove the misuse of promises
siguici Dec 24, 2024
d50f285
:bug: Fix yes and no inputs validation
siguici Dec 24, 2024
f90dfb9
:adhesive_bandage: Only use the `add` option if it is defined
siguici Dec 24, 2024
ad9c184
:white_check_mark: Test `--yes` and `no` options
siguici Dec 24, 2024
26c3baa
:adhesive_bandage: Fix conflict between force and add options
siguici Dec 24, 2024
c2981b3
:alembic: Generate test apps in labs directory
siguici Dec 24, 2024
45b0097
:technologist: Improve the way to check interactive mode
siguici Dec 24, 2024
1737f9c
:adhesive_bandage: Fix interactive mode check
siguici Dec 24, 2024
20749ee
:green_heart: Fix the test environments
siguici Dec 24, 2024
4bac5a3
:memo: Update docs
siguici Dec 24, 2024
3970c26
:children_crossing: Skip steps not necessary for adding
siguici Dec 24, 2024
1908eae
:hammer: Remove `serve` script for templates with no server adapter
siguici Dec 24, 2024
a65189f
:technologist: Do not ask to change the package name when the `yes` o…
siguici Dec 24, 2024
371d20a
:technologist: Use initial value as default value
siguici Dec 24, 2024
0f2c9a1
:fire: Remove `it` option
siguici Dec 24, 2024
2a58aa6
:recycle: Improve the definition of default options
siguici Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ node_modules/
.history
**/.vite-inspect
**/dist
**/labs/*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/tests/unit/report/
/tests/unit/coverage/
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fix: install

build: fix
pnpm build
pnpm build.create-qwikdev-astro

pr-release: test
pnpx pkg-pr-new publish ./libs/* --template ./libs/create-qwikdev-astro/stubs/templates/default/*
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"astro": "astro"
},
"dependencies": {
"@builder.io/qwik": "^1.11",
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"astro": "5.0.2"
}
Expand Down
16 changes: 8 additions & 8 deletions apps/deno-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/deno": "^5.0.1",
"@astrojs/react": "^4.0.0",
"@builder.io/qwik": "^1.11",
"@astrojs/react": "^4.1.2",
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"astro": "^5.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.3"
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"astro": "^5.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.7.2"
}
}
10 changes: 5 additions & 5 deletions apps/node-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"dependencies": {
"@astrojs/node": "9.0.0",
"@astrojs/react": "4.0.0",
"@builder.io/qwik": "^1.11",
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"astro": "5.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
}
10 changes: 5 additions & 5 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "^0.21.2",
"@qwikdev/astro": "workspace:*",
"astro": "^4.3.5",
"sharp": "^0.32.5",
"@astrojs/check": "^0.5.10",
"typescript": "^5.4.3"
"@astrojs/starlight": "^0.21.5",
"@qwikdev/astro": "workspace:*",
"astro": "^4.16.18",
"sharp": "^0.32.6",
"typescript": "^5.7.2"
}
}
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"quoteProperties": "preserve",
"quoteStyle": "double",
"semicolons": "always",
"trailingComma": "none"
"trailingCommas": "none"
}
},

Expand Down
62 changes: 33 additions & 29 deletions libs/create-qwikdev-astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@

**Types of arguments:**

| Name | Type | Default value | Description |
| :-------| :----------------| :----------------| :---------------------------------|
| project | String | ./qwik-astro-app | Directory of the project. |
| adapter | "deno" or "node" | node | Server adapter. |
| Name | Type | Default value | Description |
| :-----------| :--------------------------| :-------------| :---------------------------------|
| destination | String | . | Directory of the project. |
| adapter | "deno" or "node" or "none" | none | Server adapter. |

**Types of options:**

| Name | Description |
| :--------------------------------------| :----------------------------------------|
| `--help` (`-h`) | Display available flags. |
| `--it` | Execute actions interactively. |
| `--dry-run` | Walk through steps without executing. |
| `--force` / `--no-force` (`-f` / `--no-f`) | Overwrite target directory if it exists. |
| `--add` / `--no-add` (`-a` / `--no-a`) | Add QwikDev/astro to existing project. |
| `--install` / `--no-install` (`-i` / `--no-i`) | Install dependencies. |
| `--biome` / `--no-biome` | Prefer Biome to ESLint/Prettier. |
| `--git` / `--no-git` | Initialize Git repository. |
Expand All @@ -67,43 +67,47 @@
- Specify the command line arguments to use:

```typescript
import { runCreate } from '@qwikdev/create-astro';
import { run } from '@qwikdev/create-astro';

runCreate("./qwik-astro-app", "node", "--it");
run(["./qwik-astro-app", "node"]);
```

- Pass the arguments to create a new project:

```typescript
import { createProject } from '@qwikdev/create-astro';

const config = {
project: "./qwik-astro-app",
starter: "node",
it: false,
};

createProject(config);
```

**Project configuration type:**
**Definition type:**

```typescript
export type ProjectConfig = {
project: string;
adapter?: "deno" | "node";
export type Definition = {
destination: string;
adapter?: "deno" | "node" | "none";
force?: boolean;
add?: boolean;
install?: boolean;
biome?: boolean;
git?: boolean;
ci?: boolean;
yes: boolean;
no: boolean;
it: boolean;
dryRun: boolean;
yes?: boolean;
no?: boolean;
dryRun?: boolean;
};
```

**Default definition:**

```typescript
export const defaultDefinition = {
destination: ".",
adapter: "none",
force: undefined,
add: undefined,
install: undefined,
biome: undefined,
git: undefined,
ci: undefined,
yes: undefined,
no: undefined,
dryRun: undefined
} as const;
```

## 🌍 Community

- Follow us on [@QwikDev](https://twitter.com/QwikDev)
Expand Down
23 changes: 23 additions & 0 deletions libs/create-qwikdev-astro/bin/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { assert } from "@japa/assert";
import { configure, processCLIArgs, run } from "@japa/runner";
import { TestContext } from "@japa/runner/core";
import { PathTester } from "@qwikdev/create-astro/tester";

declare module "@japa/runner/core" {
interface TestContext {
path(path: string): PathTester;
}
}

TestContext.macro("path", function (path: string) {
return new PathTester(path);
});

processCLIArgs(process.argv.splice(2));

configure({
files: ["tests/**/*.spec.ts"],
plugins: [assert()]
});

run();
58 changes: 53 additions & 5 deletions libs/create-qwikdev-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"check": "tsc --noEmit",
"build": "pnpm check && tsup-node --env.NODE_ENV production",
"start": "tsup-node --env.NODE_ENV development --watch"
"start": "tsup-node --env.NODE_ENV development --watch",
"test": "NODE_ENV=test node --loader tsm --enable-source-maps bin/test.ts"
},
"contributors": [
{
Expand Down Expand Up @@ -41,12 +42,48 @@
"require": "./dist/index.cjs",
"default": "./dist/index.js"
},
"./app": {
"types": "./dist/app.d.ts",
"import": "./dist/app.js",
"require": "./dist/app.cjs",
"default": "./dist/app.js"
},
"./cli": {
"types": "./dist/cli.d.ts",
"import": "./dist/cli.js",
"require": "./dist/cli.cjs",
"default": "./dist/cli.js"
},
"./console": {
"types": "./dist/console.d.ts",
"import": "./dist/console.js",
"require": "./dist/console.cjs",
"default": "./dist/console.js"
},
"./core": {
"types": "./dist/core.d.ts",
"import": "./dist/core.js",
"require": "./dist/core.cjs",
"default": "./dist/core.js"
},
"./process": {
"types": "./dist/process.d.ts",
"import": "./dist/process.js",
"require": "./dist/process.cjs",
"default": "./dist/process.js"
},
"./tester": {
"types": "./dist/tester.d.ts",
"import": "./dist/tester.js",
"require": "./dist/tester.cjs",
"default": "./dist/tester.js"
},
"./utils": {
"types": "./dist/utils.d.ts",
"import": "./dist/utils.js",
"require": "./dist/utils.cjs",
"default": "./dist/utils.js"
},
"./package.json": "./package.json"
},
"files": ["dist", "stubs"],
Expand Down Expand Up @@ -75,15 +112,26 @@
},
"bugs": "https://github.com/@QwikDev/astro/issues",
"dependencies": {
"@clack/prompts": "^0.7.0",
"@clack/prompts": "^0.8.2",
"cross-spawn": "^7.0.6",
"fs-extra": "^11.2.0",
"kleur": "^4.1.5",
"which": "^5.0.0",
"which-pm-runs": "^1.1.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@japa/assert": "^3.0.0",
"@japa/runner": "^3.1.4",
"@types/cross-spawn": "^6.0.6",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.10.2",
"@types/which": "^3.0.4",
"@types/which-pm-runs": "^1.0.2",
"@types/yargs": "^17.0.32",
"tsup": "^8.2.4",
"typescript": "^5.4.5"
"@types/yargs": "^17.0.33",
"tslib": "^2.8.1",
"tsm": "^2.3.0",
"tsup": "^8.3.5",
"typescript": "^5.7.2"
}
}
Loading
Loading