@superintern/sites 0.0.0-stage → 0.1.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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +151 -2
- package/bin/sites.mjs +214 -0
- package/package.json +39 -4
- package/src/cli/api.mjs +348 -0
- package/src/cli/commands.mjs +1266 -0
- package/src/cli/environments.mjs +104 -0
- package/src/cli/git.mjs +258 -0
- package/src/cli/keys.mjs +137 -0
- package/src/cli/names.mjs +33 -0
- package/src/cli/package-info.mjs +22 -0
- package/src/cli/prompt.mjs +88 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changes to @superintern/sites
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
The first version on npm.
|
|
6
|
+
|
|
7
|
+
- `sites login`, `logout`: save a SuperIntern key in the macOS keychain, or
|
|
8
|
+
in a file only you can read; it is asked for, never taken from the command
|
|
9
|
+
line.
|
|
10
|
+
- `sites new`, `clone`: make a site, or bring an existing one's files to
|
|
11
|
+
your computer, as a git folder whose pushes ask this command for the key.
|
|
12
|
+
When git does not know who you are, commits in that folder are signed as
|
|
13
|
+
the business instead of a name git makes up.
|
|
14
|
+
- `sites list`, `status`, `status --wait`: what is online, what each push was
|
|
15
|
+
built into, and why a build failed. Inside a site's folder `status` needs
|
|
16
|
+
no name.
|
|
17
|
+
- `sites publish`, `unpublish`, `open`: put a built version online, take the
|
|
18
|
+
site offline, open its address.
|
|
19
|
+
- `sites remove`: remove a site for good, once you have typed its name
|
|
20
|
+
(`--yes` for scripts).
|
|
21
|
+
- `sites tables`, `rows`, `link`: see which of the business's CRM tables a
|
|
22
|
+
site may show, and let the site's build read them on your computer.
|
|
23
|
+
- `sites --version`.
|
|
24
|
+
- Uses SuperIntern's test service unless `--env prod` is given. Production is
|
|
25
|
+
not open yet.
|
|
26
|
+
- For macOS and Linux; on Windows, inside WSL. Needs Node.js 22.12 or newer
|
|
27
|
+
and git, and nothing else.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AMMO AI
|
|
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,152 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sites
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Make a website for a business on SuperIntern, see how it is doing, and put it
|
|
4
|
+
online, from your own computer.
|
|
5
|
+
|
|
6
|
+
A site is a folder of ordinary files that you edit, with git keeping its
|
|
7
|
+
history. `sites` makes the site, brings its files to your computer, tells you
|
|
8
|
+
what was built from each change you send, and puts the version you choose
|
|
9
|
+
online.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @superintern/sites
|
|
13
|
+
sites login
|
|
14
|
+
sites new my-shop --name "My Shop"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Before you start
|
|
18
|
+
|
|
19
|
+
- **macOS or Linux.** On Windows, use it inside WSL.
|
|
20
|
+
- **Node.js 22.12 or newer**, and **git**.
|
|
21
|
+
- **A SuperIntern key for the business** the site is for: a secret key
|
|
22
|
+
(`sk_live_…`) that may change websites (`sites.write`), or one that may only
|
|
23
|
+
look (`sites.read`). Someone who manages the business in SuperIntern makes
|
|
24
|
+
it. `sites login` asks for it; you never type it into a command.
|
|
25
|
+
|
|
26
|
+
> **Where sites go today.** Hosted sites are in an early trial. Unless told
|
|
27
|
+
> otherwise, `sites` uses SuperIntern's **test service**: a site gets the
|
|
28
|
+
> address `https://<name>.testforstuff.com`, is kept out of search engines,
|
|
29
|
+
> and needs a key made on the test service. The production service
|
|
30
|
+
> (`--env prod`, addresses under `superintern.app`) is not open yet, and
|
|
31
|
+
> `sites login --env prod` says so. A key made in the SuperIntern you use
|
|
32
|
+
> every day is a production key: the test service does not accept it.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g @superintern/sites
|
|
38
|
+
sites --version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To try it without installing: `npx @superintern/sites --help`. For real work,
|
|
42
|
+
install it: each site's folder remembers where this command is, so that
|
|
43
|
+
`git push` can ask it for your key, and a copy that `npx` fetched for one run
|
|
44
|
+
does not stay where it was. If you do move or reinstall it, run `sites link`
|
|
45
|
+
inside the site's folder.
|
|
46
|
+
|
|
47
|
+
## From nothing to a site online
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
sites login # asks for your key (it is not shown) and checks it
|
|
51
|
+
sites new my-shop --name "My Shop"
|
|
52
|
+
cd my-shop
|
|
53
|
+
npm install --ignore-scripts
|
|
54
|
+
npm run dev # work on the site at http://localhost:4321
|
|
55
|
+
npm run check # the checks every change must pass
|
|
56
|
+
git add -A && git commit -m "First version"
|
|
57
|
+
git push # sends your work. It does NOT change the live site
|
|
58
|
+
sites status --wait # waits until it has been built and checked
|
|
59
|
+
sites publish my-shop # puts that version online
|
|
60
|
+
sites open my-shop
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**A push never changes what visitors see.** Each push is built and checked and
|
|
64
|
+
becomes a numbered version. `sites publish` is the only thing that puts a
|
|
65
|
+
version online, and it only serves one that passed its checks.
|
|
66
|
+
|
|
67
|
+
## Commands
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
sites login save your key
|
|
71
|
+
sites logout remove it from this computer
|
|
72
|
+
sites new <name> --name "<business name>" make a site and bring its files to ./<name>
|
|
73
|
+
sites clone <name> bring an existing site's files here
|
|
74
|
+
sites list your sites, their state and address
|
|
75
|
+
sites status [<name>] what is online, the latest build, every version
|
|
76
|
+
sites status [<name>] --wait wait until your latest push has been built
|
|
77
|
+
sites publish <name> [--version <n>] put the newest built version (or version n) online
|
|
78
|
+
sites unpublish <name> take the site offline; its versions are kept
|
|
79
|
+
sites remove <name> remove the site for good; you type its name to confirm
|
|
80
|
+
sites open <name> open the site's address in your browser
|
|
81
|
+
sites tables [<name>] what the business's CRM lets the site show
|
|
82
|
+
sites rows <table> [<name>] the first rows of one of those tables
|
|
83
|
+
sites link in a site's folder: tie it to this copy of sites
|
|
84
|
+
sites --version which version of sites this is
|
|
85
|
+
sites --help every option
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
A site's name is 3 to 40 lowercase letters, digits and single hyphens. It
|
|
89
|
+
becomes the site's address. Inside a site's folder, `status`, `tables` and
|
|
90
|
+
`rows` need no name.
|
|
91
|
+
|
|
92
|
+
`sites status --wait` ends with exit code 0 when your push was built and is
|
|
93
|
+
ready to publish, 1 when it failed (what to fix is printed), and 2 when it
|
|
94
|
+
took too long.
|
|
95
|
+
|
|
96
|
+
To go back to an earlier version: `sites status` shows the numbers, then
|
|
97
|
+
`sites publish <name> --version <n>`.
|
|
98
|
+
|
|
99
|
+
## When a push is refused
|
|
100
|
+
|
|
101
|
+
| Git says | What to do |
|
|
102
|
+
|---|---|
|
|
103
|
+
| Authentication failed | Your saved key no longer works. Run `sites login`, then push again. |
|
|
104
|
+
| not a fast-forward | Someone else pushed first. `git pull --rebase`, run `npm run check`, push. The history of `main` cannot be rewritten. |
|
|
105
|
+
| only the main branch can be pushed | Work on `main`. |
|
|
106
|
+
| files under .github/workflows can't be changed | Follow the line git prints under it, then push again. |
|
|
107
|
+
| This push is larger than 50 MB | Send less at once. |
|
|
108
|
+
|
|
109
|
+
## Your key
|
|
110
|
+
|
|
111
|
+
- It is asked for with nothing shown on the screen, or read from a pipe
|
|
112
|
+
(`pbpaste | sites login`). There is no option and no environment variable
|
|
113
|
+
for it: a command line is kept in your shell's history.
|
|
114
|
+
- It is kept in your macOS keychain, or elsewhere in the file
|
|
115
|
+
`~/.config/superintern-sites/<service>.key`, which only you can read.
|
|
116
|
+
- It is sent to two addresses only, always over https: SuperIntern's site
|
|
117
|
+
service and its git address (below). It is never printed.
|
|
118
|
+
- Those two addresses change only if you set `SUPERINTERN_SITES_API_BASE` or
|
|
119
|
+
`SUPERINTERN_SITES_GIT_BASE` yourself, which is for running against a
|
|
120
|
+
stand-in on your own computer. Then the key goes where they say: every
|
|
121
|
+
command you run says so first ("Using …"), but `git push` asking for the
|
|
122
|
+
key in the background does not. Leave them unset.
|
|
123
|
+
- `git push` and `git pull` in a site's folder get it by asking this command,
|
|
124
|
+
through a setting in that folder's own `.git/config`. Nothing is written to
|
|
125
|
+
your global git settings, and the key is not stored in the folder.
|
|
126
|
+
- `sites logout` removes the key of the service you are on (the test
|
|
127
|
+
service unless you add `--env prod`) from this computer. To stop a key
|
|
128
|
+
working everywhere, remove it in SuperIntern.
|
|
129
|
+
|
|
130
|
+
## What it talks to
|
|
131
|
+
|
|
132
|
+
| | Test service (the default today) | Production (`--env prod`, not open yet) |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| Site service | `https://test-api.superintern.ai` | `https://api.superintern.ai` |
|
|
135
|
+
| Git address | `https://git.testforstuff.com` | `https://git.superintern.app` |
|
|
136
|
+
| A site's address | `https://<name>.testforstuff.com` | `https://<name>.superintern.app` |
|
|
137
|
+
|
|
138
|
+
Nothing else: no analytics, no update check. `sites open` starts your
|
|
139
|
+
browser, and the commands run `git` on your computer.
|
|
140
|
+
|
|
141
|
+
## Remove it
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sites logout
|
|
145
|
+
npm uninstall -g @superintern/sites
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Your sites and their folders are not touched.
|
|
149
|
+
|
|
150
|
+
## Licence
|
|
151
|
+
|
|
152
|
+
MIT. The text is in `LICENSE`, beside this file.
|
package/bin/sites.mjs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// sites: make a site, see how it is doing, and put it online.
|
|
3
|
+
// It talks to the site API and to the git address, and to nothing else.
|
|
4
|
+
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { parseArgs } from "node:util";
|
|
8
|
+
|
|
9
|
+
import { createApi } from "../src/cli/api.mjs";
|
|
10
|
+
import * as commands from "../src/cli/commands.mjs";
|
|
11
|
+
import { DEFAULT_ENVIRONMENT, resolveEnvironment } from "../src/cli/environments.mjs";
|
|
12
|
+
import { runGit } from "../src/cli/git.mjs";
|
|
13
|
+
import { defaultKeyStore } from "../src/cli/keys.mjs";
|
|
14
|
+
import { PACKAGE_VERSION } from "../src/cli/package-info.mjs";
|
|
15
|
+
import { readLine, readSecret } from "../src/cli/prompt.mjs";
|
|
16
|
+
|
|
17
|
+
const USAGE = `Usage:
|
|
18
|
+
sites login Save your key (you are asked for it; it is not shown)
|
|
19
|
+
sites new <slug> --name "<business name>"
|
|
20
|
+
Make a site and bring its files here, in ./<slug>
|
|
21
|
+
sites list Your sites
|
|
22
|
+
sites status [<slug>] Is it online, what was built, what went wrong
|
|
23
|
+
sites status [<slug>] --wait Wait until your latest push has been built
|
|
24
|
+
sites publish <slug> [--version <n>] Put the newest built version online (or version n)
|
|
25
|
+
sites unpublish <slug> Take the site offline
|
|
26
|
+
sites remove <slug> [--yes] Remove the site for good (you are asked to type its name)
|
|
27
|
+
sites open <slug> Open the site's address in the browser
|
|
28
|
+
sites clone <slug> Bring an existing site's files here
|
|
29
|
+
sites tables [<slug>] What the business's CRM lets the site show
|
|
30
|
+
sites rows <table> [<slug>] The first rows of one of those tables
|
|
31
|
+
sites link In a site's folder: tie it to this copy of sites
|
|
32
|
+
sites logout Remove your saved key
|
|
33
|
+
sites --version Which version of sites this is
|
|
34
|
+
|
|
35
|
+
In a site's folder, status, tables and rows need no <slug>. A table is named by its
|
|
36
|
+
name (in quotes when it has a space), its slug or its id.
|
|
37
|
+
|
|
38
|
+
A push never changes the live site. After a push, the site is built and
|
|
39
|
+
checked; \`sites publish\` puts the result online.
|
|
40
|
+
|
|
41
|
+
Options:
|
|
42
|
+
--env <test|prod> Which service to use. Default: ${DEFAULT_ENVIRONMENT}.
|
|
43
|
+
--name <name> With new: what the business is called.
|
|
44
|
+
--dir <folder> With new and clone: where to put the files. Default: ./<slug>.
|
|
45
|
+
--version <n> With publish: the version to put online.
|
|
46
|
+
--wait With status: wait for a build to finish. Exit code 0 when it is
|
|
47
|
+
ready to publish, 1 when it failed, 2 when it took too long.
|
|
48
|
+
--commit <id> With status --wait: the commit to wait for. Default: your latest
|
|
49
|
+
commit when run inside the site's folder.
|
|
50
|
+
--timeout <seconds> With status --wait: how long to wait. Default: 900.
|
|
51
|
+
--limit <n> With rows: how many rows to show. Default: 5. At most 50.
|
|
52
|
+
--site <slug> With tables and rows: the site, the same as naming it
|
|
53
|
+
after the command.
|
|
54
|
+
--json With list and status: print everything as JSON.
|
|
55
|
+
With tables and rows: print the service's reply.
|
|
56
|
+
--no-check With login: save the key without checking it.
|
|
57
|
+
--yes With remove: don't ask to type the site's name. For scripts.
|
|
58
|
+
|
|
59
|
+
Your key is kept in your keychain (macOS) or in a file only you can read
|
|
60
|
+
(~/.config/superintern-sites). It is never taken from the command line:
|
|
61
|
+
\`sites login\` asks for it, or reads it from a pipe.
|
|
62
|
+
|
|
63
|
+
A site's own build calls \`sites data-token --site <slug>\` to read the
|
|
64
|
+
business's public CRM tables on this computer. It is not for typing.`;
|
|
65
|
+
|
|
66
|
+
async function main() {
|
|
67
|
+
// `--version` with a number after it belongs to `sites publish`. Alone, it
|
|
68
|
+
// asks which version of the command this is.
|
|
69
|
+
const typed = process.argv.slice(2);
|
|
70
|
+
if (typed.length === 1 && (typed[0] === "--version" || typed[0] === "-v" || typed[0] === "version")) {
|
|
71
|
+
console.log(PACKAGE_VERSION);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { values, positionals } = parseArgs({
|
|
76
|
+
allowPositionals: true,
|
|
77
|
+
options: {
|
|
78
|
+
env: { type: "string" },
|
|
79
|
+
name: { type: "string" },
|
|
80
|
+
dir: { type: "string" },
|
|
81
|
+
version: { type: "string" },
|
|
82
|
+
wait: { type: "boolean" },
|
|
83
|
+
commit: { type: "string" },
|
|
84
|
+
timeout: { type: "string" },
|
|
85
|
+
json: { type: "boolean" },
|
|
86
|
+
limit: { type: "string" },
|
|
87
|
+
site: { type: "string" },
|
|
88
|
+
"no-check": { type: "boolean" },
|
|
89
|
+
yes: { type: "boolean" },
|
|
90
|
+
help: { type: "boolean", short: "h" },
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const [command, ...rest] = positionals;
|
|
94
|
+
if (values.help || !command) {
|
|
95
|
+
console.log(USAGE);
|
|
96
|
+
return values.help ? 0 : 2;
|
|
97
|
+
}
|
|
98
|
+
// Quietly ignoring it would show one site to someone who named another.
|
|
99
|
+
if (values.site !== undefined && !TAKES_SITE.has(command)) {
|
|
100
|
+
throw new Error(`\`sites ${command}\` does not take --site: it goes with tables, rows and data-token only.`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const environment = resolveEnvironment(values.env);
|
|
104
|
+
/** @type {commands.Context} */
|
|
105
|
+
const ctx = {
|
|
106
|
+
environment,
|
|
107
|
+
keys: defaultKeyStore(),
|
|
108
|
+
api: (key) => createApi({ base: environment.api, key }),
|
|
109
|
+
git: runGit,
|
|
110
|
+
out: (line = "") => console.log(line),
|
|
111
|
+
note: (line = "") => console.error(line),
|
|
112
|
+
cwd: process.cwd(),
|
|
113
|
+
self: { node: process.execPath, script: fileURLToPath(import.meta.url) },
|
|
114
|
+
readSecret: () => readSecret(`Paste your key for ${environment.name} (it will not be shown): `),
|
|
115
|
+
ask: readLine,
|
|
116
|
+
openUrl,
|
|
117
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
118
|
+
now: Date.now,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Git calls this many times and reads the answer: nothing else may be printed.
|
|
122
|
+
if (command === "git-credential") {
|
|
123
|
+
return commands.gitCredential(ctx, rest[0] ?? "", await readAll());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (environment.overridden) {
|
|
127
|
+
ctx.note(`Using ${environment.api} and ${environment.git} (set by SUPERINTERN_SITES_API_BASE / SUPERINTERN_SITES_GIT_BASE).`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const slug = rest[0] ?? "";
|
|
131
|
+
switch (command) {
|
|
132
|
+
case "login":
|
|
133
|
+
return commands.login(ctx, { check: !values["no-check"] });
|
|
134
|
+
case "logout":
|
|
135
|
+
return commands.logout(ctx);
|
|
136
|
+
case "new":
|
|
137
|
+
return commands.newSite(ctx, slug, { name: values.name, dir: values.dir });
|
|
138
|
+
case "clone":
|
|
139
|
+
return commands.cloneExisting(ctx, slug, { dir: values.dir });
|
|
140
|
+
case "list":
|
|
141
|
+
return commands.list(ctx, { json: values.json });
|
|
142
|
+
case "status":
|
|
143
|
+
return commands.status(ctx, slug, {
|
|
144
|
+
json: values.json,
|
|
145
|
+
wait: values.wait,
|
|
146
|
+
commit: values.commit,
|
|
147
|
+
timeoutSeconds: values.timeout === undefined ? undefined : positiveNumber(values.timeout, "--timeout"),
|
|
148
|
+
});
|
|
149
|
+
case "publish":
|
|
150
|
+
return commands.publish(ctx, slug, { version: values.version });
|
|
151
|
+
case "unpublish":
|
|
152
|
+
return commands.unpublish(ctx, slug);
|
|
153
|
+
case "remove":
|
|
154
|
+
return commands.remove(ctx, slug, { yes: values.yes });
|
|
155
|
+
case "open":
|
|
156
|
+
return commands.open(ctx, slug);
|
|
157
|
+
case "tables":
|
|
158
|
+
return commands.tables(ctx, slug, { json: values.json, site: values.site });
|
|
159
|
+
case "rows":
|
|
160
|
+
return commands.rows(ctx, rest[0], rest[1], { json: values.json, limit: values.limit, site: values.site });
|
|
161
|
+
case "link":
|
|
162
|
+
return commands.link(ctx);
|
|
163
|
+
// A site's build runs this and reads the one line it prints.
|
|
164
|
+
case "data-token":
|
|
165
|
+
return commands.dataToken(ctx, { site: values.site, slug });
|
|
166
|
+
default:
|
|
167
|
+
throw new UsageError(`Unknown command: ${command}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
class UsageError extends Error {}
|
|
172
|
+
|
|
173
|
+
/** The commands that can be told their site with `--site` as well as after the command. */
|
|
174
|
+
const TAKES_SITE = new Set(["tables", "rows", "data-token"]);
|
|
175
|
+
|
|
176
|
+
/** @param {string} value @param {string} flag */
|
|
177
|
+
function positiveNumber(value, flag) {
|
|
178
|
+
const number = Number(value);
|
|
179
|
+
if (!Number.isFinite(number) || number <= 0) throw new UsageError(`${flag} needs a number of seconds`);
|
|
180
|
+
return number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** @returns {Promise<string>} */
|
|
184
|
+
function readAll() {
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
let text = "";
|
|
187
|
+
process.stdin.setEncoding("utf8");
|
|
188
|
+
process.stdin.on("data", (chunk) => (text += chunk));
|
|
189
|
+
process.stdin.on("end", () => resolve(text));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** @param {string} url */
|
|
194
|
+
function openUrl(url) {
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
// Only ever an https address of a site; passed as one argument, with no shell.
|
|
197
|
+
if (!/^https:\/\//.test(url)) return resolve(undefined);
|
|
198
|
+
const child = spawn(process.platform === "darwin" ? "open" : "xdg-open", [url], { stdio: "ignore", detached: true });
|
|
199
|
+
child.on("error", () => resolve(undefined));
|
|
200
|
+
child.on("spawn", () => {
|
|
201
|
+
child.unref();
|
|
202
|
+
resolve(undefined);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
main().then(
|
|
208
|
+
(code) => process.exit(code),
|
|
209
|
+
(error) => {
|
|
210
|
+
console.error(`sites: ${error.message}`);
|
|
211
|
+
if (error instanceof UsageError) console.error(`\n${USAGE}`);
|
|
212
|
+
process.exit(error instanceof UsageError ? 2 : (error.exitCode ?? 1));
|
|
213
|
+
},
|
|
214
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superintern/sites",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Make a website for a business on SuperIntern, see how it is doing, and put it online.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"superintern",
|
|
7
|
+
"website",
|
|
8
|
+
"hosting",
|
|
9
|
+
"static-site",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": {
|
|
15
|
+
"sites": "bin/sites.mjs"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md",
|
|
21
|
+
"bin/sites.mjs",
|
|
22
|
+
"src/cli/api.mjs",
|
|
23
|
+
"src/cli/commands.mjs",
|
|
24
|
+
"src/cli/environments.mjs",
|
|
25
|
+
"src/cli/git.mjs",
|
|
26
|
+
"src/cli/keys.mjs",
|
|
27
|
+
"src/cli/names.mjs",
|
|
28
|
+
"src/cli/package-info.mjs",
|
|
29
|
+
"src/cli/prompt.mjs"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.12"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|