@supersdk/supercli 0.1.2-staging.9 → 0.2.0-staging.13
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/dist/commands/createApp.js +274 -7
- package/dist/commands/createApp.js.map +1 -1
- package/dist/commands/publishSite.js +218 -91
- package/dist/commands/publishSite.js.map +1 -1
- package/dist/config/appConfig.js +187 -0
- package/dist/config/appConfig.js.map +1 -0
- package/dist/createApp/copyTemplate.js +337 -45
- package/dist/createApp/copyTemplate.js.map +1 -1
- package/dist/publish/siteConfig.js +352 -165
- package/dist/publish/siteConfig.js.map +1 -1
- package/dist/publish/siteZip.js +7 -2
- package/dist/publish/siteZip.js.map +1 -1
- package/dist/store/backends/encryptedFile.js +44 -8
- package/dist/store/backends/encryptedFile.js.map +1 -1
- package/dist/template/README.md +59 -9
- package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +1 -1
- package/dist/template/ios/Sources/App/AppDelegate.swift +1 -1
- package/dist/template/scripts/android_snapshot_canary.py +1 -1
- package/dist/template/scripts/build_android.sh +1 -1
- package/dist/template/scripts/build_ios.sh +5 -10
- package/dist/template/scripts/serve_web.py +15 -3
- package/dist/template/scripts/supersdk_template.py +164 -140
- package/dist/template/scripts/web_package.py +65 -8
- package/dist/template/super_build.sh +2 -2
- package/dist/template/supersdk.json +23 -0
- package/dist/template/web/src/js/app.js +5 -2
- package/dist/util/fsAtomic.js +3 -2
- package/dist/util/fsAtomic.js.map +1 -1
- package/dist/util/prompt.js +23 -0
- package/dist/util/prompt.js.map +1 -1
- package/dist/util/shell.js +21 -0
- package/dist/util/shell.js.map +1 -0
- package/package.json +1 -1
- package/dist/template/supersdk.yaml +0 -16
package/dist/publish/siteZip.js
CHANGED
|
@@ -42,7 +42,9 @@ exports.buildSiteZip = buildSiteZip;
|
|
|
42
42
|
//
|
|
43
43
|
// Rules:
|
|
44
44
|
// - REQUIRE a root index.html (else a local error, no upload).
|
|
45
|
-
// - exclude
|
|
45
|
+
// - exclude the root supersdk.json (SITE_CONFIG_FILENAME — the retired
|
|
46
|
+
// super-site.yml is no longer a thing) + dotfiles/dotdirs, but KEEP
|
|
47
|
+
// .well-known/.
|
|
46
48
|
// - reject symlinks + path traversal + case-insensitive duplicate paths.
|
|
47
49
|
// - per-entry <= 25 MiB, file count <= 2000, compressed archive <= 50 MiB.
|
|
48
50
|
const fs = __importStar(require("node:fs"));
|
|
@@ -87,7 +89,10 @@ function collectEntries(root, limits) {
|
|
|
87
89
|
if (name === '..' || name === '.' || name.includes('\\') || name.includes('/')) {
|
|
88
90
|
throw new ZipBuildError('PATH_TRAVERSAL', `非法的路径条目: ${rel}`);
|
|
89
91
|
}
|
|
90
|
-
// Exclusions: root
|
|
92
|
+
// Exclusions: root supersdk.json + dotfiles/dotdirs (keep .well-known/).
|
|
93
|
+
// The root config carries spid/orgId — packaging it would publish the
|
|
94
|
+
// project's identity to a public site whenever the publish dir IS the
|
|
95
|
+
// repo root (single-page site repos).
|
|
91
96
|
if (relPrefix === '' && name === siteConfig_1.SITE_CONFIG_FILENAME)
|
|
92
97
|
continue;
|
|
93
98
|
if (isExcludedSegment(name))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siteZip.js","sourceRoot":"","sources":["../../src/publish/siteZip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"siteZip.js","sourceRoot":"","sources":["../../src/publish/siteZip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,oCA2DC;AArMD,iFAAiF;AACjF,+EAA+E;AAC/E,8EAA8E;AAC9E,uDAAuD;AACvD,EAAE;AACF,SAAS;AACT,iEAAiE;AACjE,yEAAyE;AACzE,wEAAwE;AACxE,oBAAoB;AACpB,2EAA2E;AAC3E,6EAA6E;AAC7E,4CAA8B;AAC9B,gDAAkC;AAClC,2CAA6B;AAC7B,6C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AM,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -89,6 +89,34 @@ function readVault() {
|
|
|
89
89
|
function writeVault(vault) {
|
|
90
90
|
(0, fsAtomic_1.atomicWriteFileSync)(vaultPath(), JSON.stringify(vault, null, 2));
|
|
91
91
|
}
|
|
92
|
+
function vaultLockPath() {
|
|
93
|
+
return `${vaultPath()}.lock`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 读-改-写全程持跨进程锁,与 accountStore.withAccountsLock 同一把原语。
|
|
97
|
+
*
|
|
98
|
+
* 🔴 没有它就会丢账号:整份 vault 是一个文件、一次整体写回,两个 supercli 进程各自
|
|
99
|
+
* readVault → 改自己那条 entry → writeVault,后写者会把先写者刚提交的 entry 整条抹掉。
|
|
100
|
+
* atomicWriteFileSync 的 temp+rename 只保证文件不半截,**不防 lost update**。
|
|
101
|
+
* 更隐蔽的是丢失不会被察觉:accounts.json 是另一把锁保护的、仍显示账号 active,
|
|
102
|
+
* 直到下一条命令报「本地未找到有效凭据」。
|
|
103
|
+
*
|
|
104
|
+
* 口令提示与 scrypt(~16MiB、上百毫秒)一律留在锁**外**:锁内等用户敲口令会让持锁时间
|
|
105
|
+
* 变成人类量级,不但阻塞其他进程,还可能超过 staleMs 被判为废锁而遭窃取。
|
|
106
|
+
*/
|
|
107
|
+
function withVaultLock(mutate) {
|
|
108
|
+
const release = (0, fsAtomic_1.acquireLockSync)(vaultLockPath(), { label: 'credential vault' });
|
|
109
|
+
try {
|
|
110
|
+
// 必须在锁内重读:锁外读到的可能已被其他进程改写。
|
|
111
|
+
const current = readVault();
|
|
112
|
+
const { next, result } = mutate(current);
|
|
113
|
+
writeVault(next);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
release();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
92
120
|
function deriveKey(passphrase, salt) {
|
|
93
121
|
return crypto.scryptSync(passphrase, salt, SCRYPT_KEYLEN, SCRYPT_PARAMS);
|
|
94
122
|
}
|
|
@@ -107,6 +135,8 @@ function createEncryptedFileBackend(getPassphrase) {
|
|
|
107
135
|
return true;
|
|
108
136
|
},
|
|
109
137
|
get(accountKey) {
|
|
138
|
+
// 只读,不取锁:writeVault 走 temp+rename,读者只会看到「改前」或「改后」的
|
|
139
|
+
// 完整文件,不存在半截读。取锁反而会让每次读都去等写者,而 get 还要提示口令。
|
|
110
140
|
const vault = readVault();
|
|
111
141
|
const entry = vault.entries[accountKey];
|
|
112
142
|
if (!entry)
|
|
@@ -139,23 +169,29 @@ function createEncryptedFileBackend(getPassphrase) {
|
|
|
139
169
|
const plaintext = Buffer.from(JSON.stringify(secret), 'utf8');
|
|
140
170
|
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
141
171
|
const tag = cipher.getAuthTag();
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
// 加密产物与 vault 的其他 entry 无关,所以口令提示 + scrypt 都在锁外完成,
|
|
173
|
+
// 锁内只做「重读 → 塞进一条 entry → 写回」这段极短的临界区。
|
|
174
|
+
const entry = {
|
|
144
175
|
salt: salt.toString('base64'),
|
|
145
176
|
iv: iv.toString('base64'),
|
|
146
177
|
tag: tag.toString('base64'),
|
|
147
178
|
ciphertext: ciphertext.toString('base64'),
|
|
148
179
|
};
|
|
149
|
-
|
|
180
|
+
withVaultLock((current) => ({
|
|
181
|
+
next: { ...current, entries: { ...current.entries, [accountKey]: entry } },
|
|
182
|
+
result: undefined,
|
|
183
|
+
}));
|
|
150
184
|
},
|
|
151
185
|
delete(accountKey) {
|
|
152
186
|
// Deleting never needs the passphrase — it only removes the entry, it
|
|
153
187
|
// does not need to decrypt it first.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
188
|
+
withVaultLock((current) => {
|
|
189
|
+
if (!current.entries[accountKey])
|
|
190
|
+
return { next: current, result: undefined };
|
|
191
|
+
const entries = { ...current.entries };
|
|
192
|
+
delete entries[accountKey];
|
|
193
|
+
return { next: { ...current, entries }, result: undefined };
|
|
194
|
+
});
|
|
159
195
|
},
|
|
160
196
|
};
|
|
161
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryptedFile.js","sourceRoot":"","sources":["../../../src/store/backends/encryptedFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"encryptedFile.js","sourceRoot":"","sources":["../../../src/store/backends/encryptedFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgHA,gEAoEC;AApLD,uEAAuE;AACvE,uEAAuE;AACvE,2EAA2E;AAC3E,oEAAoE;AACpE,sDAAsD;AACtD,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,2EAA2E;AAC3E,0EAA0E;AAC1E,oCAAoC;AACpC,oDAAsC;AACtC,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAClC,kDAA2E;AAe3E,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,yEAAyE;AACzE,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,MAAM,aAAa,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAIjD,SAAS,SAAS;IAChB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IACrF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CA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|
3
3
|
This directory is the copy-ready `app_repo_example` template scaffold for
|
|
4
|
-
Android, iOS, and Web hosts. Edit one root `supersdk.
|
|
4
|
+
Android, iOS, and Web hosts. Edit one root `supersdk.json`, run plan or build
|
|
5
5
|
from this directory, and use the root ordered summary to inspect platform
|
|
6
6
|
results.
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ through the root build orchestration described below.
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
No arguments are equivalent to `./super_build.sh --plan`. Plan mode validates
|
|
21
|
-
`supersdk.
|
|
21
|
+
`supersdk.json` and prints Android -> iOS -> Web helper order without invoking
|
|
22
22
|
platform build helpers or emitting `SUPERSDK_BUILD_SUMMARY_JSON=`.
|
|
23
23
|
|
|
24
24
|
Build mode validates and injects managed config first, then runs selected
|
|
@@ -29,23 +29,73 @@ rewritten.
|
|
|
29
29
|
|
|
30
30
|
## Configuration Checklist
|
|
31
31
|
|
|
32
|
-
- Edit `supersdk.
|
|
33
|
-
- Keep `
|
|
32
|
+
- Edit `supersdk.json`. It is standard JSON: no comments, no trailing commas.
|
|
33
|
+
- Keep `"schemaVersion": 2`.
|
|
34
34
|
- Set `spid`, `environment`, and `name`. Replace the example `demo0001` with
|
|
35
35
|
the real 8-character lowercase alphanumeric spid issued by the console.
|
|
36
|
-
- Keep `environment: prod` for production, or use an explicit 1–10 character
|
|
36
|
+
- Keep `"environment": "prod"` for production, or use an explicit 1–10 character
|
|
37
37
|
lowercase alphanumeric environment such as `staging`.
|
|
38
|
-
- Set `android.package` for Android builds.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
- Set `android.package` for Android builds. It is required whenever Android is
|
|
39
|
+
built and must differ from the fixed `com.supersdk.simple` namespace.
|
|
40
|
+
- Set `ios.bundleId` for iOS builds. It is required whenever iOS is built: the
|
|
41
|
+
app identity is never derived from `spid`, so a missing value fails the build
|
|
42
|
+
instead of shipping under the SDK's own reverse-domain namespace. The default
|
|
43
|
+
`"spmMode": "mock"` uses the bundled `ios/MockSuperSDKPackage`.
|
|
41
44
|
- Set `web.host` for Web packaging.
|
|
42
45
|
- Run `./super_build.sh --plan`.
|
|
43
46
|
- Run `./super_build.sh --build` or a single-platform build.
|
|
44
47
|
|
|
48
|
+
`orgId` and `sites` are owned by `supercli`. The template type-checks them
|
|
49
|
+
(`orgId` a string, `sites` an array) and otherwise ignores them, so site-side
|
|
50
|
+
changes can never break an App build. Any other unrecognized root key is kept
|
|
51
|
+
as-is. The retired `supersdk.yaml` / `supersdk.yml` / `super-site.yml` files are
|
|
52
|
+
rejected with a copy-pasteable migration command; there is no silent fallback.
|
|
53
|
+
The command matches the situation: with no usable `supersdk.json` it writes the
|
|
54
|
+
full skeleton first and deletes the legacy file last, and when `supersdk.json` is
|
|
55
|
+
already valid it only offers `rm <legacy>` so pasting it cannot overwrite real
|
|
56
|
+
values.
|
|
57
|
+
|
|
58
|
+
`supersdk.json` must be standard JSON in the strict sense. `NaN`, `Infinity`, and
|
|
59
|
+
`-Infinity` are rejected even though Python's parser accepts them, because
|
|
60
|
+
`supercli` reads the same file with `JSON.parse`, which does not.
|
|
61
|
+
|
|
62
|
+
Note that the top-level `environment` is the App's own SDK runtime environment
|
|
63
|
+
(injected into all three native configs), while `sites[].env` is the project
|
|
64
|
+
environment a site publishes into. They are not asserted to be equal: building
|
|
65
|
+
with a `staging` SDK config and publishing to a `prod` site is a legal
|
|
66
|
+
combination.
|
|
67
|
+
|
|
45
68
|
Generated files live under each platform `.supersdk/managed/` directory and
|
|
46
69
|
are safe to overwrite only when they contain `managed_by: supersdk-template`.
|
|
47
70
|
Use `--force` only when intentionally replacing unmanaged target files.
|
|
48
71
|
|
|
72
|
+
## Web Output And Publishing
|
|
73
|
+
|
|
74
|
+
`web/src` is authored input. The Web build renders the single publishable
|
|
75
|
+
package root at `web/dist`:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
./super_build.sh --platform web --build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
That writes `web/dist/` (static assets plus the generated
|
|
82
|
+
`web/dist/supersdk-config.json` the browser fallback reads) and the offline
|
|
83
|
+
package `output/<host>@<version>@<md5>.zip`, both from the same tree. The zip is
|
|
84
|
+
not a byte-identical copy of `web/dist`: it also carries the offline manifest
|
|
85
|
+
`__super_meta.json`, which belongs to the offline package only. `web/dist`
|
|
86
|
+
is the directory to hand to the site publisher:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
supercli publish-site web/dist --spid <spid> --slug <slug> --env <env> --version <x.y.z>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`web/dist` is a build output: it is gitignored and replaced wholesale on every
|
|
93
|
+
build. Never edit it by hand, and never point the publisher at `web/src` — that
|
|
94
|
+
tree has no runtime config and still carries `js/supersdk.provenance.json`.
|
|
95
|
+
|
|
96
|
+
For local debugging, `python3 scripts/serve_web.py` serves `web/dist` when it
|
|
97
|
+
exists and falls back to the unbuilt `web/src` with a warning.
|
|
98
|
+
|
|
49
99
|
## Ordered Summary
|
|
50
100
|
|
|
51
101
|
Build mode writes exactly one root-owned machine-readable stdout line:
|
|
@@ -133,7 +183,7 @@ python3 supersimples/tests/e2e/build_orchestration_smoke.py
|
|
|
133
183
|
```
|
|
134
184
|
|
|
135
185
|
The canonical smoke copies this template to a temporary directory outside the
|
|
136
|
-
monorepo, edits `supersdk.
|
|
186
|
+
monorepo, edits `supersdk.json`, verifies platform entry assets, pins Android
|
|
137
187
|
SNAPSHOT metadata to a local fixture, forces Android deterministic test mode,
|
|
138
188
|
forces deterministic iOS `SKIP_XCODEGEN_MISSING`, runs the root build, checks
|
|
139
189
|
the ordered summary, checks all three managed configs, verifies a real Web zip
|
|
@@ -15,7 +15,7 @@ public class SimpleApplication extends Application {
|
|
|
15
15
|
try {
|
|
16
16
|
SuperSDK.init(this, BuildConfig.SUPERSDK_SPID, BuildConfig.SUPERSDK_ENVIRONMENT, new SuperSDKProvider() {});
|
|
17
17
|
} catch (RuntimeException exception) {
|
|
18
|
-
Log.e(TAG, "SuperSDK init failed; check supersdk.
|
|
18
|
+
Log.e(TAG, "SuperSDK init failed; check supersdk.json and the resolved SDK dependency.", exception);
|
|
19
19
|
throw exception;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -9,7 +9,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
|
9
9
|
do {
|
|
10
10
|
try SimpleSDKBootstrap.initialize()
|
|
11
11
|
} catch {
|
|
12
|
-
fatalError("SuperSDK init failed; check supersdk.
|
|
12
|
+
fatalError("SuperSDK init failed; check supersdk.json identity: \(error)")
|
|
13
13
|
}
|
|
14
14
|
return true
|
|
15
15
|
}
|
|
@@ -95,7 +95,7 @@ def effective_android_version(root, config_path):
|
|
|
95
95
|
version = managed_android_version(root)
|
|
96
96
|
if version is not None:
|
|
97
97
|
return version
|
|
98
|
-
normalized = supersdk_template.load_and_validate(config_path
|
|
98
|
+
normalized = supersdk_template.load_and_validate(config_path)
|
|
99
99
|
supersdk_template.require_android_config(normalized)
|
|
100
100
|
return normalized["sdk"]["androidVersion"]
|
|
101
101
|
|
|
@@ -4,7 +4,7 @@ set -euo pipefail
|
|
|
4
4
|
APP_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
5
|
ANDROID_ROOT="$APP_ROOT/android"
|
|
6
6
|
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
|
7
|
-
CONFIG="$APP_ROOT/supersdk.
|
|
7
|
+
CONFIG="$APP_ROOT/supersdk.json"
|
|
8
8
|
|
|
9
9
|
usage() {
|
|
10
10
|
echo "Usage: scripts/build_android.sh --build [--config path]" >&2
|
|
@@ -34,12 +34,6 @@ def swift_string(value):
|
|
|
34
34
|
return json.dumps(str(value))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def sanitize_spid(spid):
|
|
38
|
-
value = re.sub(r"[^a-z0-9-]+", "-", spid.lower())
|
|
39
|
-
value = re.sub(r"-+", "-", value).strip("-")
|
|
40
|
-
return value or "app"
|
|
41
|
-
|
|
42
|
-
|
|
43
37
|
def load_template_contract(app_root):
|
|
44
38
|
helper_path = app_root / "scripts" / "supersdk_template.py"
|
|
45
39
|
spec = importlib.util.spec_from_file_location("supersdk_template_contract", helper_path)
|
|
@@ -116,11 +110,12 @@ version_code = version.get("code")
|
|
|
116
110
|
if not template_contract.is_positive_int(version_code):
|
|
117
111
|
fail_invalid("version.code must be a positive integer")
|
|
118
112
|
|
|
113
|
+
# No derived fallback: the app identity comes from ios.bundleId or the build fails.
|
|
119
114
|
bundle_id = platform_config.get("bundleId")
|
|
120
|
-
if bundle_id is
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
if bundle_id is None:
|
|
116
|
+
fail_invalid(f"platform_config.bundleId is required; set ios.bundleId in {template_contract.CONFIG_FILENAME}")
|
|
117
|
+
if not isinstance(bundle_id, str) or not re.fullmatch(template_contract.BUNDLE_ID_PATTERN, bundle_id):
|
|
118
|
+
fail_invalid("platform_config.bundleId must be a bundle identifier")
|
|
124
119
|
mock_package = (ios_dir / "MockSuperSDKPackage").resolve()
|
|
125
120
|
source_spec = ios_dir / "project.yml"
|
|
126
121
|
|
|
@@ -23,9 +23,21 @@ def main(argv=None):
|
|
|
23
23
|
args = parser.parse_args(argv)
|
|
24
24
|
|
|
25
25
|
root = args.root.resolve()
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
# Prefer the built package root: only web/dist carries the generated
|
|
27
|
+
# supersdk-config.json that the browser fallback path reads.
|
|
28
|
+
entry = None
|
|
29
|
+
for relative in ("web/dist/index.html", "web/src/index.html"):
|
|
30
|
+
if (root / relative).is_file():
|
|
31
|
+
entry = relative
|
|
32
|
+
break
|
|
33
|
+
if entry is None:
|
|
34
|
+
print(f"web/dist/index.html or web/src/index.html not found under {root}", file=sys.stderr)
|
|
28
35
|
return 1
|
|
36
|
+
if entry.startswith("web/src/"):
|
|
37
|
+
print(
|
|
38
|
+
"warning: serving unbuilt web/src; run scripts/build_web.sh --build for the browser config fallback",
|
|
39
|
+
file=sys.stderr,
|
|
40
|
+
)
|
|
29
41
|
|
|
30
42
|
remote_bind = args.host not in {"127.0.0.1", "localhost", "::1"}
|
|
31
43
|
if remote_bind and not args.allow_remote:
|
|
@@ -37,7 +49,7 @@ def main(argv=None):
|
|
|
37
49
|
handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=str(root))
|
|
38
50
|
server = http.server.ThreadingHTTPServer((args.host, args.port), handler)
|
|
39
51
|
host, port = server.server_address
|
|
40
|
-
print(f"http://{host}:{port}/
|
|
52
|
+
print(f"http://{host}:{port}/{entry}", flush=True)
|
|
41
53
|
try:
|
|
42
54
|
server.serve_forever()
|
|
43
55
|
except KeyboardInterrupt:
|