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

feat: add initial CLI code #64

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@
"vcs": {
"clientKind": "git",
"enabled": true
}
},

"extends": ["./libs/create-design-system/biome.json"]
}
2 changes: 2 additions & 0 deletions libs/create-design-system/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/
tsconfig.json
Empty file.
116 changes: 116 additions & 0 deletions libs/create-design-system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Create @qwikdev/astro 🎉

## Scaffolding for [QwikDev/astro](https://github.com/QwikDev/astro) projects

### 🛠️ CLI

- **With `NPM`**:

```bash
npm create @qwikdev/astro@latest [project] [adapter] [...options]
```

- **With `Yarn`**:

```bash
yarn create @qwikdev/astro [project] [adapter] [...options]
```

- **With `PNPM`**:

```bash
pnpm create @qwikdev/astro [project] [adapter] [...options]
```

- **With `Bun`**:

```bash
bun create @qwikdev/astro [project] [adapter] [...options]
```

The `create @qwikdev/astro` command runs interactively without any arguments or options.

However, it is possible to use the interactive mode as described below:

**Types of arguments:**

| Name | Type | Default value | Description |
| :-------| :----------------| :----------------| :---------------------------------|
| project | String | ./qwik-astro-app | Directory of the project. |
| adapter | "deno" or "node" | node | 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. |
| `--install` / `--no-install` (`-i` / `--no-i`) | Install dependencies. |
| `--biome` / `--no-biome` | Prefer Biome to ESLint/Prettier. |
| `--git` / `--no-git` | Initialize Git repository. |
| `--ci` / `--no-ci` | Add CI workflow. |
| `--yes` (`-y`) | Skip all prompts by accepting defaults. |
| `--no` (`-n`) | Skip all prompts by declining defaults. |

### 📦 API

- Use the arguments provided in the command line:

```typescript
import createQwikAstro from '@qwikdev/create-astro';

createQwikAstro();
```

- Specify the command line arguments to use:

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

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

- 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:**

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

## 🌍 Community

- Follow us on [@QwikDev](https://twitter.com/QwikDev)
- Ping us at [@QwikDev](https://twitter.com/QwikDev)
- Join our [Discord](https://qwik.dev/chat) community

## 🔗 Related

- [Qwik](https://qwik.dev/)
- [Astro](https://astro.build/)
20 changes: 20 additions & 0 deletions libs/create-design-system/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"organizeImports": {
"ignore": ["dist", "stubs"]
},
"linter": {
"include": ["src"],
"ignore": ["dist", "stubs"],
"rules": {
"style": {
"noParameterAssign": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"formatter": {
"ignore": ["dist", "stubs"]
}
}
1 change: 1 addition & 0 deletions libs/create-design-system/dist/cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env node
3 changes: 3 additions & 0 deletions libs/create-design-system/dist/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
"use strict";
import("./index.js").then((createQwikDevAstro) => createQwikDevAstro.default());
40 changes: 40 additions & 0 deletions libs/create-design-system/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/// <reference types="node" />
export declare function isHome(dir: string): boolean;
export declare function resolveAbsoluteDir(dir: string): string;
export declare function resolveRelativeDir(dir: string): string;
export declare function $(cmd: string, args: string[], cwd: string): {
abort: () => Promise<void>;
install: Promise<boolean>;
};
export declare function isUnicodeSupported(): boolean;
export declare const note: (message?: string, title?: string) => void;
export declare function panic(msg: string): void;
export declare const clearDir: (dir: string) => Promise<void[]>;
export declare function fileGetContents(file: string): string;
export declare function filePutContents(file: string, contents: string): void;
export declare function fileReplaceContents(file: string, search: string | RegExp, replace: string): void;
export declare function getPackageManager(): string;
export declare const isPackageManagerInstalled: (packageManager: string) => Promise<unknown>;
export declare function pmRunCommand(): string;
export declare function replacePackageJsonRunCommand(dir: string): void;
export declare function panicCanceled(): void;
export declare const $pm: (args: string | string[], cwd?: string, env?: NodeJS.ProcessEnv) => Promise<unknown>;
export declare const installDependencies: (cwd: string) => Promise<void>;
export type ProjectConfig = {
project: string;
adapter?: "deno" | "node";
force?: boolean;
install?: boolean;
biome?: boolean;
git?: boolean;
ci?: boolean;
yes: boolean;
no: boolean;
it: boolean;
dryRun: boolean;
};
export declare function parseArgs(args: string[]): ProjectConfig;
export declare function createProject(config: ProjectConfig, defaultProject: string): Promise<void>;
/** @param args Pass here process.argv.slice(2) */
export declare function runCreate(...args: string[]): Promise<void>;
export default function (): Promise<void>;
Loading