create-tern 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +18 -2
- package/index.js +32 -0
- package/package.json +26 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Tern Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-tern
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Creates a [Tern](https://github.com/Unfield/Tern) app: Svelte on the client, Go on the server.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create tern@latest
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It asks where to put the project, which template to start from, whether to style it with Tern UI, and whether to create a git repository and install packages. To skip the questions, pass a directory and flags:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm create tern@latest my-app -- -template blog -ui -git -install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Tern needs [Go](https://go.dev/dl/). This package runs `tern new` from the matching Tern release, the same as:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
go run github.com/Unfield/Tern/cmd/tern@latest new my-app
|
|
19
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// npm create tern@latest [directory] [-- flags]
|
|
3
|
+
//
|
|
4
|
+
// Runs `tern new` from the Tern release matching this package's version, so
|
|
5
|
+
// the prompts, templates and flags are the CLI's own. Tern needs Go.
|
|
6
|
+
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
|
|
10
|
+
const { version } = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
11
|
+
const ref = `github.com/Unfield/Tern/cmd/tern@${version === '0.0.0' ? 'latest' : `v${version}`}`;
|
|
12
|
+
|
|
13
|
+
const go = spawnSync('go', ['version'], { encoding: 'utf8' });
|
|
14
|
+
if (go.error || go.status !== 0) {
|
|
15
|
+
console.error(
|
|
16
|
+
'\n Tern needs Go, which wasn\'t found on your PATH.\n' +
|
|
17
|
+
' Install it from https://go.dev/dl/ and run this again.\n'
|
|
18
|
+
);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const result = spawnSync('go', ['run', ref, 'new', ...args], {
|
|
24
|
+
stdio: 'inherit',
|
|
25
|
+
// An older Go downloads the toolchain Tern needs.
|
|
26
|
+
env: { GOTOOLCHAIN: 'auto', ...process.env }
|
|
27
|
+
});
|
|
28
|
+
if (result.error) {
|
|
29
|
+
console.error(result.error.message);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tern",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Create a Tern app: npm create tern@latest",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-tern": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Unfield/Tern.git",
|
|
19
|
+
"directory": "packages/create-tern"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Unfield/Tern",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"tern",
|
|
24
|
+
"svelte",
|
|
25
|
+
"go",
|
|
26
|
+
"create"
|
|
27
|
+
]
|
|
28
|
+
}
|