@anansi/cli 1.1.68 → 1.2.0

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 (4) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +23 -0
  3. package/package.json +12 -4
  4. package/run.js +32 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.0](https://github.com/ntucker/anansi/compare/@anansi/cli@1.1.70...@anansi/cli@1.2.0) (2022-05-29)
7
+
8
+
9
+ ### 🚀 Features
10
+
11
+ * Add anansi serve command ([#1525](https://github.com/ntucker/anansi/issues/1525)) ([ac5a396](https://github.com/ntucker/anansi/commit/ac5a396f9640ce18058813c1594d49367a8aa468))
12
+
13
+
14
+
15
+ ### [1.1.70](https://github.com/ntucker/anansi/compare/@anansi/cli@1.1.69...@anansi/cli@1.1.70) (2022-05-28)
16
+
17
+
18
+ ### 📦 Package
19
+
20
+ * Update all non-major dependencies ([#1523](https://github.com/ntucker/anansi/issues/1523)) ([1fdc897](https://github.com/ntucker/anansi/commit/1fdc897d632269e0405946419f632156aef71a14))
21
+
22
+
23
+
24
+ ### [1.1.69](https://github.com/ntucker/anansi/compare/@anansi/cli@1.1.68...@anansi/cli@1.1.69) (2022-05-28)
25
+
26
+ **Note:** Version bump only for package @anansi/cli
27
+
28
+
29
+
30
+
31
+
6
32
  ### [1.1.68](https://github.com/ntucker/anansi/compare/@anansi/cli@1.1.67...@anansi/cli@1.1.68) (2022-05-24)
7
33
 
8
34
  **Note:** Version bump only for package @anansi/cli
package/README.md CHANGED
@@ -58,3 +58,26 @@ Features can be incrementally adopted by running sub-generators from an existing
58
58
  cd my-app-name
59
59
  anansi add testing
60
60
  ```
61
+
62
+ ## Running SSR
63
+
64
+ ```bash
65
+ Usage: anansi serve [options] <entrypath>
66
+
67
+ runs server for SSR projects
68
+
69
+ Arguments:
70
+ entrypath Path to entrypoint
71
+
72
+ Options:
73
+ -p, --pubPath <path> Where to serve assets from
74
+ -d, --dev Run devserver rather than using previously compiled output
75
+ -h, --help display help for command
76
+ ```
77
+
78
+ ```json
79
+ {
80
+ "start": "anansi serve --dev ./src/index.tsx",
81
+ "start:prod": "anansi serve --pubPath=/assets/ ./dist-server/App.js",
82
+ }
83
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anansi/cli",
3
- "version": "1.1.68",
3
+ "version": "1.2.0",
4
4
  "description": "Fast React Web Apps",
5
5
  "homepage": "https://github.com/ntucker/anansi/tree/master/packages/cli#readme",
6
6
  "repository": {
@@ -47,20 +47,28 @@
47
47
  "jest"
48
48
  ],
49
49
  "engines": {
50
- "node": ">= 12.10.0",
50
+ "node": ">= 12.20.0",
51
51
  "npm": ">= 6.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@anansi/generator-js": "^8.0.5",
54
+ "@anansi/generator-js": "^8.0.7",
55
55
  "bin-version-check": "^4.0.0",
56
56
  "chalk": "^4.1.2",
57
- "commander": "^9.2.0",
57
+ "commander": "^9.3.0",
58
58
  "execa": "^5.1.1",
59
59
  "latest-version": "^5.1.0",
60
60
  "mem-fs": "^2.2.1",
61
61
  "mem-fs-editor": "^9.4.0",
62
62
  "yo": "^4.3.0"
63
63
  },
64
+ "peerDependencies": {
65
+ "@anansi/core": "^0.8.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@anansi/core": {
69
+ "optional": true
70
+ }
71
+ },
64
72
  "jest": {
65
73
  "testEnvironment": "node"
66
74
  },
package/run.js CHANGED
@@ -102,4 +102,36 @@ program
102
102
  }
103
103
  });
104
104
 
105
+ program
106
+ .command('serve')
107
+ .description('runs server for SSR projects')
108
+ .argument('<entrypath>', 'Path to entrypoint')
109
+ .option('-p, --pubPath <path>', 'Where to serve assets from')
110
+ .option(
111
+ '-d, --dev',
112
+ 'Run devserver rather than using previously compiled output',
113
+ )
114
+ .action(async (entrypath, options) => {
115
+ try {
116
+ const { serve, devServe } = await import('@anansi/core/scripts');
117
+
118
+ if (options.pubPath) process.env.WEBPACK_PUBLIC_PATH = options.pubPath;
119
+ else if (!process.env.WEBPACK_PUBLIC_PATH)
120
+ process.env.WEBPACK_PUBLIC_PATH = '/assets/';
121
+
122
+ if (options.dev) {
123
+ devServe(entrypath);
124
+ } else {
125
+ serve(entrypath);
126
+ }
127
+ } catch (error) {
128
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
129
+ console.error('@anansi/core must be installed to run this subcommand');
130
+ } else {
131
+ console.error(error.message);
132
+ }
133
+ process.exit(2);
134
+ }
135
+ });
136
+
105
137
  program.parse(process.argv);