@soroush.design/cli 0.2.0-alpha.1 → 0.2.0-alpha.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.
package/README.md CHANGED
@@ -1,113 +1,21 @@
1
1
  # @soroush.design/cli
2
2
 
3
- The command line of the [`@soroush.tech`](https://docs.soroush.tech) design system. It has two
4
- commands: `create` starts a new app on the design system, and `init` sets the design system up in
5
- an existing React app.
3
+ The command line of the [`@soroush.tech`](https://docs.soroush.tech) design system.
6
4
 
7
- ## Start a new app: `create`
5
+ - **`create`** starts a new app: a working boilerplate on the design system, with its theme, its
6
+ providers and a few pages in place, ready to build on.
7
+ - **`init`** sets the design system up in a React app you already have.
8
8
 
9
9
  ```sh
10
- npx @soroush.tech/design-system create my-app
10
+ npx @soroush.design/cli create my-app
11
+ npx @soroush.design/cli init
11
12
  ```
12
13
 
13
- It makes the app in a new folder, `my-app`, or in an empty one, and never writes in a folder that
14
- holds anything. It asks for what you did not give it - the name, TypeScript or JavaScript, the
15
- default color scheme, whether to add sample data pages - then shows every file and the install, and writes nothing before a yes.
16
- It installs with the package manager you ran it with (`npx`, `pnpm dlx`, `yarn dlx`, `bunx`), with
17
- no scripts, and runs `git init` with no commit, unless the folder is already in a repository. When
18
- a write or the install fails, it takes the new app away.
14
+ Each shows every change first, and writes nothing until you say yes. `--help` after a command
15
+ lists its options.
19
16
 
20
- | Option | What it does |
21
- | -------------------- | --------------------------------------------------------- |
22
- | `-y`, `--yes` | Create without asking: TypeScript and light, unless given |
23
- | `--dry-run` | Show the files and exit |
24
- | `--title <text>` | What the app's pages call it: the name when not given |
25
- | `--framework <name>` | The app's framework: `vike`, the default and only one yet |
26
- | `--ts`, `--js` | TypeScript (the default) or JavaScript |
27
- | `--scheme <name>` | The default color scheme: `light` or `dark` |
28
- | `--sample-data` | Add the sample data pages |
29
- | `--no-git` | Do not run `git init` |
30
- | `-h`, `--help` | Show the options of `create` |
31
-
32
- ### The Vike app
33
-
34
- A [Vike](https://vike.dev) app, isomorphic: every page is prerendered to HTML at build time, with
35
- the styles it uses, so it is drawn styled before any script runs. Then the app takes over in the
36
- browser and moves between pages without a reload.
37
-
38
- - `src/pages/` holds the pages - a home page, a second page and a 404 page - built from the design
39
- system's components and theme tokens only.
40
- - `src/pages/+Layout` is the frame every page renders in. It renders `<Providers>`, and holds a
41
- light and dark switch.
42
- - `src/theme/themes` holds a `light` and a `dark` theme, as `init` writes them: make them your own.
43
- - `src/pages/+onRenderHtml` and `+onRenderClient` render the pages with the design system's
44
- Emotion cache. There is no renderer package to install.
45
- - `npm run dev` starts it, `npm run build` builds it, and `npm run preview` serves the build.
46
-
47
- With sample data pages, it also shows how data gets onto a page, with no data library:
48
-
49
- - `src/data/items` holds six sample items.
50
- - `/items` lists them, and `/items/<id>` shows one. Each page's `+data` reads the items at build
51
- time, and the build prerenders one page per item. Moving between them in the browser loads only
52
- their data, with no reload.
53
- - A page reads its data with `useData()`, from `src/pages/usePageContext`. Make the `+data` hooks
54
- fetch your own data, and remove `src/data/items`.
55
-
56
- The switch does not remember the scheme across a reload, and the theme's fonts are not loaded: see
57
- the [fonts guide](https://docs.soroush.tech/design-system/getting-started/installation/#fonts).
58
-
59
- ## Set up an existing app: `init`
60
-
61
- Run it in your app's folder, or in a workspace's root that holds one app:
62
-
63
- ```sh
64
- npx @soroush.tech/design-system init
65
- ```
66
-
67
- The design system ships this command line, so that installs the version you ask for. Run on its
68
- own, `npx @soroush.design/cli init` (or `create`) does the same with the design system version it
69
- was released next to.
70
-
71
- In PowerShell, quote the package name: `@` starts a splat there.
72
-
73
- ```powershell
74
- npx '@soroush.tech/design-system' init
75
- ```
76
-
77
- ### Options of `init`
78
-
79
- | Option | What it does |
80
- | ----------------- | -------------------------------------------- |
81
- | `-y`, `--yes` | Apply without asking |
82
- | `--dry-run` | Show the changes and exit |
83
- | `--force` | Run outside git, or with uncommitted changes |
84
- | `--scheme <name>` | The default color scheme: `light` or `dark` |
85
- | `-h`, `--help` | Show the options of `init` |
86
-
87
- ### What `init` does
88
-
89
- In a client-rendered React app, whatever builds it (Vite, webpack, Rspack, Parcel, Create React
90
- App), in TypeScript or JavaScript:
91
-
92
- - It writes `src/theme/themes` (a `light` and a `dark` theme, each a `createTheme(baseTheme,
93
- {...})` call you edit) and `src/theme/Providers` (`ThemeProvider` with the base page styles).
94
- - It wraps what your root renders in `<Providers>`.
95
- - It installs `@soroush.tech/design-system` with your own package manager.
96
-
97
- It is careful with your app:
98
-
99
- - It shows every change first - the files, each edit as a diff, the install - and writes nothing
100
- before a yes.
101
- - It runs only in a git repository with no uncommitted change, unless `--force`.
102
- - It never overwrites a file, and edits the root only when it has the standard shape: one
103
- `createRoot(...).render(` or `ReactDOM.render(` call. Otherwise it prints the lines to add.
104
- - When a write fails, it takes back every change it made. The install runs last, with no scripts.
105
- - A second run finds its own files and changes nothing.
106
- - It checks your React against the design system's peer range, and never upgrades React.
107
- - It reaches no network but the install.
108
-
109
- Next.js, Vike and React Router apps are refused for now, with a pointer to the
110
- [setup guide](https://docs.soroush.tech/design-system/getting-started/installation/).
17
+ **Documentation:** [docs.soroush.tech/cli](https://docs.soroush.tech/cli/) - every question and
18
+ option, the app `create` makes, and what `init` changes.
111
19
 
112
20
  ## License
113
21
 
package/dist/bin.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { n as main, r as version$1, t as createNodeIo } from "./io-2De2zuH0.mjs";
2
+ import { n as main, r as version$1, t as createNodeIo } from "./io-Bybgct-f.mjs";
3
3
  // ../design-system/package.json
4
4
  var name = "@soroush.tech/design-system";
5
- var version = "2.3.0";
5
+ var version = "2.2.0";
6
6
  var peerDependencies = {
7
7
  "react": "^18.0.0 || ^19.0.0",
8
8
  "react-dom": "^18.0.0 || ^19.0.0"
package/dist/index.d.mts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { Readable, Writable } from "node:stream";
2
+ /** One answer a choice offers. */
3
+ interface Choice {
4
+ /** What the command gets back. */
5
+ value: string;
6
+ /** What the person reads. */
7
+ label: string;
8
+ }
2
9
  interface RunOptions {
3
10
  cwd: string;
4
11
  env?: Record<string, string>;
@@ -17,12 +24,22 @@ interface Io {
17
24
  isInteractive: boolean;
18
25
  write: (text: string) => void;
19
26
  ask: (question: string) => Promise<string>;
27
+ /**
28
+ * Asks for one of `choices`, picked with the arrow keys, starting on `initial`. Rejects with a
29
+ * `CancelledError` on Ctrl+C or Escape.
30
+ */
31
+ select: (question: string, choices: readonly Choice[], initial?: number) => Promise<string>;
32
+ /** Asks for any of `choices`, toggled with space, starting with `initial` picked. */
33
+ selectMany: (question: string, choices: readonly Choice[], initial?: readonly string[]) => Promise<string[]>;
20
34
  run: (command: string, args: readonly string[], options: RunOptions) => RunResult;
21
35
  }
36
+ type Terminal = Readable & {
37
+ isTTY?: boolean;
38
+ isRaw?: boolean;
39
+ setRawMode?: (mode: boolean) => unknown;
40
+ };
22
41
  interface NodeIoOptions {
23
- stdin?: Readable & {
24
- isTTY?: boolean;
25
- };
42
+ stdin?: Terminal;
26
43
  stdout?: Writable & {
27
44
  isTTY?: boolean;
28
45
  };
@@ -31,6 +48,7 @@ interface NodeIoOptions {
31
48
  }
32
49
  export declare function createNodeIo({ stdin, stdout, platform, cwd }?: NodeIoOptions): Io;
33
50
  type Scheme = 'light' | 'dark';
51
+ type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun';
34
52
  interface PackageJson {
35
53
  name?: string;
36
54
  version?: string;
@@ -52,9 +70,23 @@ interface PackageJson {
52
70
  export declare function readDesignSystemPackage(fromFile: string): PackageJson;
53
71
  /**
54
72
  * Reads the command line and runs the command, for `designSystem`: the package of
55
- * `@soroush.tech/design-system` the command installs. Returns the exit code.
73
+ * `@soroush.tech/design-system` the command installs. Returns the exit code: 130 when the person
74
+ * stops it at a question, which is before anything is written.
56
75
  */
57
76
  declare function main(argv: readonly string[], io: Io, designSystem: PackageJson): Promise<number>;
77
+ /** A library `create` can add to a new app, with its wiring and a small example. */
78
+ type Library = 'tanstack-query' | 'swr' | 'msw' | 'zustand' | 'jotai' | 'redux-toolkit' | 'react-hook-form' | 'vitest';
79
+ /**
80
+ * How the app's pages are rendered: `isomorphic`, prerendered to HTML at build time and then
81
+ * moving between pages in the browser; `spa`, rendered in the browser only; `ssg`, HTML only, with
82
+ * no JavaScript in the browser.
83
+ */
84
+ type Rendering = 'isomorphic' | 'spa' | 'ssg';
85
+ /**
86
+ * How the repository holds the app: `workspace`, as `apps/web` of a workspace that has room for
87
+ * more apps and services; `standalone`, the app alone at the root.
88
+ */
89
+ type Layout = 'workspace' | 'standalone';
58
90
  interface CreateOptions {
59
91
  /** The app's folder: asked for, or `my-app`, when missing. */
60
92
  name: string | undefined;
@@ -64,6 +96,14 @@ interface CreateOptions {
64
96
  framework: string | undefined;
65
97
  /** TypeScript or JavaScript: asked for, or TypeScript, when missing. */
66
98
  isTypeScript: boolean | undefined;
99
+ /** The package manager to install with: asked for, or the one that ran create, when missing. */
100
+ packageManager: PackageManagerName | undefined;
101
+ /** How the repository holds the app: asked for, or a workspace, when missing. */
102
+ layout: Layout | undefined;
103
+ /** How the pages are rendered: asked for, or isomorphic, when missing. */
104
+ rendering: Rendering | undefined;
105
+ /** The libraries to add: asked for, or none, when missing. */
106
+ libraries: readonly Library[] | undefined;
67
107
  scheme: Scheme | undefined;
68
108
  /** Adds the pages that read sample data: asked for, or not, when missing. */
69
109
  hasSampleData: boolean | undefined;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as createNodeIo, n as default, i as readDesignSystemPackage } from "./io-2De2zuH0.mjs";
1
+ export { t as createNodeIo, n as default, i as readDesignSystemPackage } from "./io-Bybgct-f.mjs";