@codua/codeoutline-win32-x64 0.1.3 → 0.1.4

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/DISTRIBUTION.md CHANGED
@@ -112,9 +112,10 @@ codeoutline update
112
112
  codeoutline update --rollback
113
113
  ```
114
114
 
115
- `serve` checks for updates before starting. A verified update applies to that new
116
- process; existing services keep running. Failed checks retain the local version.
117
- Other commands select a verified installed version without requesting the network.
115
+ Every command starts the newest verified installed version without requesting the
116
+ network. `serve` then checks for updates in a background thread, so an unreachable
117
+ update server never delays startup or requests; a verified update applies to the
118
+ next launch, and failed checks are reported on stderr.
118
119
  Set `CODEOUTLINE_AUTO_UPDATE=0` to disable automatic checks. Manual update still works.
119
120
  Rollback switches between the two installed versions; after the first update it
120
121
  returns to the initial installation. Accepted sequence numbers are retained, so a
@@ -131,15 +132,102 @@ Treat these overrides and the initial installation as trusted configuration.
131
132
 
132
133
  To publish, stage a fresh native package for each target with
133
134
  `UPDATE_SEQUENCE=N`; N must increase for every release (the 0.1.3 baseline is 3).
134
- Use XUpgate's `tools/release.py` with the same version and sequence,
135
- `--entry scripts/codeoutline/command.lua`, and
136
- `--runtime bin/xnet.exe` for Windows or `--runtime bin/xnet` otherwise.
137
- Sign the native directory with the project's offline private key, upload the signed
138
- artifact in XUpgate, then publish its version to the desired channel. The updater
135
+ Use `tools/update-release.lua` for a script-only change: it reuses the previous
136
+ platform runtimes, replaces Lua scripts and native launchers, and produces signed
137
+ complete bundles for all three platforms. Upload these as drafts before publishing
138
+ the version to the desired channel. The updater
139
139
  checks signatures, file hashes, platform, version, sequence and runtime health
140
140
  before activating the directory. CI must produce each platform runtime; a Windows
141
141
  package cannot update a Linux or macOS installation.
142
142
 
143
+ ### Make an all-platform script update with xnet
144
+
145
+ For automatic releases, commit the feature changes and the release tools first,
146
+ then run one command from a clean `main` checkout:
147
+
148
+ ```powershell
149
+ .\bin\xnet.exe tools/release.lua LOG_STDERR=1 LOG_FILE=0
150
+ ```
151
+
152
+ The tool prompts for a new version and rejects versions already present in local
153
+ or remote tags, any XUpgate release (including drafts), npm, or the output folder.
154
+ It assigns the next unused update sequence, runs local tests, updates the source
155
+ version and sequence files, commits only those files as `release: <version>`, and
156
+ pushes the commit and tag atomically. Full mode waits for the tagged GitHub Actions
157
+ CI, downloads and verifies artifacts for that exact commit, signs and uploads all
158
+ three XUpgate drafts, publishes the three npm platform packages then the entry
159
+ package, creates the GitHub release, and finally switches XUpgate stable.
160
+
161
+ Full mode requires Git, Node/npm, OpenSSL and GitHub CLI (`gh`) on PATH, a signed-in
162
+ GitHub account (`gh auth login`), and npm credentials usable for publishing. npm
163
+ may still ask for account-required authentication; configure appropriate publishing
164
+ credentials before attempting unattended releases. Private key and administrator
165
+ credential defaults match the local development setup; `KEY`, `CREDENTIAL_FILE`,
166
+ `URL`, `CA_FILE`, and `RELEASE_DIR` override them.
167
+
168
+ Pass `PROXY=socks5://127.0.0.1:1080` (or set `CODEOUTLINE_RELEASE_PROXY`) when
169
+ GitHub access requires a proxy. The tool uses SOCKS remote DNS (`socks5h`) and
170
+ applies the proxy to Git, GitHub CLI, npm, and XUpgate requests, including child
171
+ upload/publish commands. It changes neither global Git/npm configuration nor the
172
+ calling terminal's proxy environment.
173
+
174
+ For script changes that only need XUpgate, use `MODE=update`. It reuses baseline
175
+ runtimes, checks that their runtime commit matches the current submodule, and does
176
+ not require GitHub CLI or npm publishing authentication:
177
+
178
+ ```powershell
179
+ .\bin\xnet.exe tools/release.lua MODE=update BASE=C:/release/0.1.3 LOG_STDERR=1 LOG_FILE=0
180
+ ```
181
+
182
+ This mode still commits/pushes the release version and tag; CI runs on the tag but
183
+ the local tool does not wait for or publish its npm/GitHub artifacts. npm read
184
+ access remains necessary for duplicate-version checks. The initial npm launcher
185
+ is only upgraded by full npm publication, not an XUpgate script bundle.
186
+
187
+ Use `DRY_RUN=1` to exercise prompting and remote version checks without changing
188
+ files, commits, tags or publications. An explicit `VERSION` is also accepted; a
189
+ duplicate then stops instead of prompting. The default output is `C:/release/<version>`
190
+ on Windows and `dist/releases/<version>` elsewhere. Signed bundles are under
191
+ `<output>/bundles/xupgate`. Full mode stores the downloaded CI artifacts under
192
+ `<output>/ci`. `release-state.json` records the chosen version, sequence and commit.
193
+
194
+ Failures stop the release. Already-created commits/tags, immutable uploads and npm
195
+ versions are retained rather than reverted. Inspect the error before retrying;
196
+ after a partial release, use the recorded version and existing artifacts with the
197
+ individual upload/publish commands instead of rebuilding that version.
198
+
199
+ Run from the repository root. `BASE` contains the extracted CI packages under
200
+ `codeoutline-<target>/native/package`. `OUTPUT` must be a new directory.
201
+ Python is not required. OpenSSL must be on PATH for offline private-key signing;
202
+ the tool verifies each signature against the bundled public key before saving it.
203
+ It verifies the base packages' recorded hashes and preserves their runtime commits.
204
+ Manual bundles record the real source commit/dirty state and are not marked as CI
205
+ release builds. Review and test the staged files before uploading.
206
+
207
+ ```powershell
208
+ .\bin\xnet.exe tools/update-release.lua ACTION=build BASE=C:/release/0.1.3 OUTPUT=C:/release/0.1.4 VERSION=0.1.4 SEQUENCE=4 KEY=C:/private/codeoutline.private.pem LOG_STDERR=1 LOG_FILE=0
209
+ ```
210
+
211
+ Native directories are written under `OUTPUT/native/<target>`. Uploadable signed
212
+ JSON files are under `OUTPUT/xupgate/<target>.json`. The private key is never
213
+ included. The version argument sets the staged version without editing the source
214
+ checkout; npm's Node launcher is outside these native bundles.
215
+
216
+ Use administrator credentials via `XUPGATE_PUBLISH_TOKEN` or an environment file
217
+ containing one `ADMIN_TOKEN=...` line. Credentials are read without printing them.
218
+ The upload step checks existing remote hashes, so an interrupted upload can be
219
+ retried with the same artifacts. Do not rebuild or overwrite an uploaded version.
220
+
221
+ ```powershell
222
+ .\bin\xnet.exe tools/update-release.lua ACTION=upload OUTPUT=C:/release/0.1.4 VERSION=0.1.4 SEQUENCE=4 CREDENTIAL_FILE=C:/private/xupgate-admin.env LOG_STDERR=1 LOG_FILE=0
223
+ .\bin\xnet.exe tools/update-release.lua ACTION=publish OUTPUT=C:/release/0.1.4 VERSION=0.1.4 SEQUENCE=4 CHANNEL=stable CREDENTIAL_FILE=C:/private/xupgate-admin.env LOG_STDERR=1 LOG_FILE=0
224
+ ```
225
+
226
+ `ACTION=publish` verifies that all three matching platform releases exist before
227
+ switching the channel. Both network actions default to the packaged HTTPS server
228
+ and pinned CA; `URL` and `CA_FILE` can override them for another deployment.
229
+ Existing services keep running; an installed update applies on the next launch.
230
+
143
231
  The opt-in deployed integration test needs Python, OpenSSL, a staged Windows
144
232
  package, and the sibling XUpgate release builder:
145
233
 
package/bin/xnet.exe CHANGED
Binary file
package/build-info.json CHANGED
@@ -1 +1 @@
1
- {"sourceDirty":false,"releaseReady":true,"version":"0.1.3","sha256":{"scripts/codeoutline/lang/c.lua":"1251352bcfac6b6d3704460e00b06cf4f41232144748b41b89db04a5ab594073","scripts/codeoutline/version.lua":"635bc8cc8a89fcfedfe2a3eaafaa6a061f84f72f832b0e39f98f302ba997ffda","scripts/codeoutline/parse.lua":"ccda7a087dc90109fce7a1e64ebe1de0d7c7036990b81b3423ff14b4299bf38f","scripts/codeoutline/command.lua":"a2e6f938897407f99573779b71948968cd743e331ca2cd0076cc1a9170559c30","scripts/codeoutline/lang/cpp.lua":"96aebcd8972d5272c11446257f37fe90c10f4130c3c1b5bb71c793d7c25456f4","scripts/codeoutline/common.lua":"ee775ed5b2f7ada7a02851f44b51bd4008bceacbf9700576a474e6732e3c03c2","scripts/codeoutline/lang/csharp.lua":"36ac648b8691c85b8c75d5bcb146fcdfc87992a278e4798f3eb194124e3df2bb","codeoutline":"8d00b52027511d56136c8bd345666d2a14ad49591313c80a016d6032f708c02b","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/control.lua":"1dfbea9f1397d9fb3c321c48a8d8ee7fc7928e864588226e55247bd548255bb4","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","scripts/codeoutline/lang/go.lua":"f5717cbeabe6d30dad72c473fa445480d7fb6b5546bb262e5f4c46185f0959da","scripts/xupgate/client.lua":"4bcefd14802f5d44c7c7e5b5aeda25247957212605f426da8c9dfb84ed7f9758","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/explore.lua":"d9e4e0d0179d00205df96ad0e7442e7bbc87e27481e6d27eb772ca302b5f35d3","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/lang/java.lua":"435b6ddcd231679db9e705a604344a3fb6c00b84cc20b2ecd210423ee0b376a6","scripts/xupgate/common.lua":"7eb979277887dfae16b325ffdab493673f01b96d00b9c1de11d8aca297368752","scripts/codeoutline/graph.lua":"1ef35f2e92e9db3bbe9b612bb0cb336a9b57b440c9a066e7ba3ef81574326834","scripts/codeoutline/lang/js.lua":"7a25a195356deeef7da3fdaf6e8a483b2a3a230cae3064e5dde2a3556fdcbda9","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","scripts/codeoutline/http.lua":"33802130445b348ce607e9891d4a9789d34b18338bf5d296f56e0b3c7b0c5493","codeoutline.cmd":"6414f7fac4c7e384d5b8e9e5e8a89731f7950b48dbe08bcbe149c1a70dbc4407","scripts/codeoutline/lang/lua.lua":"33b038192425e4db29251674e30c73b7a1af849789c49ff6430ee409c062f812","DISTRIBUTION.md":"da25de66601fe22f19ee35a61b5880a1bc65c4ca81bafefb9c46fdbbfb3436da","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/index.lua":"08c585a7cb264962ac04beb3bf5bc8a9dd22b4f85644b6fdd6a4e527843fbee9","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","README.md":"a1757e831f9d60d14cf318bd47cf8d9481a3e65b7bf99922064445d5d4913c89","scripts/codeoutline/lang/python.lua":"f7219c04914673ee6bae387c222b09acd433596c746237bdd6650a4f4087b17c","README.zh-CN.md":"4c2ff0fe0b73b3052f067926e45f9f9792571d9d529c731567b2c0d3b1d2c844","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/index_worker.lua":"47f80807a458d5c706b1a54f60fb2200ae51f022b21d9039df44611035e9ac40","scripts/codeoutline/service.lua":"597c435309abc0d8149b5e88095896c3bba6516146fd587d53b4b6fbf23a553c","THIRD_PARTY.md":"a70238f26ec05b7be4b813fa49c337cfb4d3cd64c36fcd27401d121e0e6e38df","scripts/codeoutline/lang/rust.lua":"f7c21751b1ab08512a406f45bd53546dddfa98ff680b1374d29a4152ae110023","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/rpmalloc.txt":"f6c10eb9ec349900767c3dcb8bc71fe4fba2aefea329f05e2608827188016c0f","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/main.lua":"287c48d3006bf94fcf84e5e14b9a0a7379857c450f05bd850e3cb29119615d90","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/updater.lua":"772b097af670f2d61fb92e51b9862c2964f90cd911b7720c6b1ae6906082b7f0","scripts/codeoutline/cli.lua":"ba996c3c3def65aab08ba60141a7a98a19dfcc1bbe004ab5d8ea14a7f9f9a08b","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","bin/xnet.exe":"33ecdb8cd80d3df1bf610dd3d0ba89c0010f408626860645c82620eb5db2e3fd","scripts/codeoutline/xscan.lua":"508d1fdccee4e856e0f198992bec45d7c8a9a3c191e0a5f71717741db9e00325"},"updateSequence":3,"note":"Release build from a clean checkout","target":"win32-x64","lua":"LuaJIT 2.1.1774896198","sourceCommit":"9a786639b6cfb46257bec1ff45fe038063270ed3","runtimeCommit":"f2c3ddfcbd3f04d7dd71543d0878d06e033519a0"}
1
+ {"sha256":{"scripts/codeoutline/explore.lua":"d9e4e0d0179d00205df96ad0e7442e7bbc87e27481e6d27eb772ca302b5f35d3","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/js.lua":"7a25a195356deeef7da3fdaf6e8a483b2a3a230cae3064e5dde2a3556fdcbda9","scripts/codeoutline/graph.lua":"1ef35f2e92e9db3bbe9b612bb0cb336a9b57b440c9a066e7ba3ef81574326834","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/lang/lua.lua":"33b038192425e4db29251674e30c73b7a1af849789c49ff6430ee409c062f812","scripts/codeoutline/update_worker.lua":"b067e2ca95e729cb6b392171a2ddd80d06f7c313f3ab0484978664940364eb68","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/lang/python.lua":"f7219c04914673ee6bae387c222b09acd433596c746237bdd6650a4f4087b17c","scripts/codeoutline/version.lua":"955291f8ce69995ab9b24f691bbc2b5bed4b768242c077ae15c1fcb270cb4791","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/codeoutline/lang/rust.lua":"f7c21751b1ab08512a406f45bd53546dddfa98ff680b1374d29a4152ae110023","scripts/codeoutline/xscan.lua":"508d1fdccee4e856e0f198992bec45d7c8a9a3c191e0a5f71717741db9e00325","codeoutline":"8d00b52027511d56136c8bd345666d2a14ad49591313c80a016d6032f708c02b","codeoutline.cmd":"6414f7fac4c7e384d5b8e9e5e8a89731f7950b48dbe08bcbe149c1a70dbc4407","scripts/codeoutline/main.lua":"0a340e38b5a86753091d72f07a379203656fc39feaa3b54e505a8e93a6deefb0","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","README.zh-CN.md":"4c2ff0fe0b73b3052f067926e45f9f9792571d9d529c731567b2c0d3b1d2c844","licenses/rpmalloc.txt":"f6c10eb9ec349900767c3dcb8bc71fe4fba2aefea329f05e2608827188016c0f","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","README.md":"a1757e831f9d60d14cf318bd47cf8d9481a3e65b7bf99922064445d5d4913c89","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/xupgate/client.lua":"4bcefd14802f5d44c7c7e5b5aeda25247957212605f426da8c9dfb84ed7f9758","scripts/codeoutline/cli.lua":"ba996c3c3def65aab08ba60141a7a98a19dfcc1bbe004ab5d8ea14a7f9f9a08b","DISTRIBUTION.md":"3b5b1ee53e37873a9fc0c4c65e590f63c42bf989fbd3e2e2ebce5565cbc578af","scripts/codeoutline/parse.lua":"ccda7a087dc90109fce7a1e64ebe1de0d7c7036990b81b3423ff14b4299bf38f","THIRD_PARTY.md":"a70238f26ec05b7be4b813fa49c337cfb4d3cd64c36fcd27401d121e0e6e38df","scripts/codeoutline/lang/c.lua":"1251352bcfac6b6d3704460e00b06cf4f41232144748b41b89db04a5ab594073","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/xupgate/common.lua":"7eb979277887dfae16b325ffdab493673f01b96d00b9c1de11d8aca297368752","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","scripts/codeoutline/command.lua":"a2e6f938897407f99573779b71948968cd743e331ca2cd0076cc1a9170559c30","scripts/codeoutline/index.lua":"08c585a7cb264962ac04beb3bf5bc8a9dd22b4f85644b6fdd6a4e527843fbee9","scripts/codeoutline/update_sequence.lua":"cb35cf7e03925c2e901c14aee2deae88aaaff6922644b2f73b428dcba8020e90","scripts/codeoutline/lang/cpp.lua":"96aebcd8972d5272c11446257f37fe90c10f4130c3c1b5bb71c793d7c25456f4","scripts/codeoutline/lang/csharp.lua":"36ac648b8691c85b8c75d5bcb146fcdfc87992a278e4798f3eb194124e3df2bb","bin/xnet.exe":"20e40fbc28bc1496bb3f598c5776cb93a56cc74fccade4d6994c3f4e390580e0","scripts/codeoutline/service.lua":"597c435309abc0d8149b5e88095896c3bba6516146fd587d53b4b6fbf23a553c","scripts/codeoutline/control.lua":"1dfbea9f1397d9fb3c321c48a8d8ee7fc7928e864588226e55247bd548255bb4","scripts/codeoutline/common.lua":"ee775ed5b2f7ada7a02851f44b51bd4008bceacbf9700576a474e6732e3c03c2","scripts/codeoutline/index_worker.lua":"47f80807a458d5c706b1a54f60fb2200ae51f022b21d9039df44611035e9ac40","scripts/codeoutline/lang/go.lua":"f5717cbeabe6d30dad72c473fa445480d7fb6b5546bb262e5f4c46185f0959da","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","scripts/codeoutline/http.lua":"33802130445b348ce607e9891d4a9789d34b18338bf5d296f56e0b3c7b0c5493","scripts/codeoutline/updater.lua":"633348e78ca018afca33bfedd3f17340a6400462bd3b5aaa6c57e83919d76f2a","scripts/codeoutline/lang/java.lua":"435b6ddcd231679db9e705a604344a3fb6c00b84cc20b2ecd210423ee0b376a6"},"updateSequence":4,"runtimeCommit":"f2c3ddfcbd3f04d7dd71543d0878d06e033519a0","lua":"LuaJIT 2.1.1774896198","version":"0.1.4","sourceCommit":"23b74bb62f48d65049d60ae36eb3501b4f713f56","target":"win32-x64","releaseReady":true,"note":"Release build from a clean checkout","sourceDirty":false}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@codua/codeoutline-win32-x64","publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","repository":{"type":"git","url":"git+https://github.com/1dao/codeoutline.git"},"files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"version":"0.1.3","os":["win32"]}
1
+ {"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"version":"0.1.4","name":"@codua/codeoutline-win32-x64","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"os":["win32"]}
@@ -43,6 +43,7 @@ end
43
43
  local shared = assert(xshared.create('codeoutline_control', 65536, 256))
44
44
  local jobs, next_id, job_count, worker_ready = {}, 0, 0, false
45
45
  local endpoint, stdio, input = nil, nil, ''
46
+ local updating = false
46
47
  local startup = xtimer.now_ms()
47
48
 
48
49
  local function submit(req, done)
@@ -67,6 +68,10 @@ return {
67
68
  __init = function()
68
69
  assert(xnet.init())
69
70
  assert(xthread.create_thread(2, 'INDEX', scripts .. '/codeoutline/index_worker.lua'))
71
+ -- Launchers enable this for serve. Updating never delays or blocks requests.
72
+ if os.getenv('CODEOUTLINE_AUTO_UPDATE') == '1' then
73
+ updating = xthread.create_thread(3, 'UPDATE', scripts .. '/codeoutline/update_worker.lua') and true
74
+ end
70
75
  if options.STDIO == '1' then
71
76
  assert(xutils.read_stdin, 'Rebuild runtime for nonblocking stdin support')
72
77
  stdio = mcp.new(config, submit, cancel)
@@ -96,6 +101,10 @@ return {
96
101
  elseif op == 'worker_result' then
97
102
  local job = jobs[id]
98
103
  if job then jobs[id], job_count = nil, job_count - 1; job.done(ok, result) end
104
+ elseif op == 'update_result' then
105
+ -- Arguments: error, installed version (nil when already current).
106
+ if id then notice('update unavailable: ' .. tostring(id))
107
+ elseif ok then notice('update ' .. tostring(ok) .. ' installed; restart to use it') end
99
108
  end
100
109
  end,
101
110
  __update = function()
@@ -127,6 +136,7 @@ return {
127
136
  if stdio then stdio:close() end
128
137
  if endpoint then endpoint.close() end
129
138
  xthread.shutdown_thread(2)
139
+ if updating then xthread.shutdown_thread(3) end
130
140
  xnet.uninit()
131
141
  end,
132
142
  }
@@ -0,0 +1 @@
1
+ return 4
@@ -0,0 +1,20 @@
1
+ -- Background update thread: network, verification and installation stay off the
2
+ -- service thread. An installed update applies to the next launch.
3
+ local source = assert(xutils.realpath(debug.getinfo(1, 'S').source:sub(2))):gsub('\\', '/')
4
+ local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'))
5
+ package.path = scripts .. '/?.lua;' .. package.path
6
+ local updater = require('codeoutline.updater')
7
+
8
+ return {
9
+ __init = function()
10
+ assert(xnet.init()); xtimer.init(16)
11
+ local ok, err = pcall(function()
12
+ require('xupgate.client').open(updater.config()).update(function(update_error, result)
13
+ xthread.post(1, 'update_result', update_error, result and result.version)
14
+ end)
15
+ end)
16
+ if not ok then xthread.post(1, 'update_result', tostring(err)) end
17
+ end,
18
+ __uninit = function() xnet.uninit() end,
19
+ __thread_handle = function() end,
20
+ }
@@ -4,7 +4,7 @@ local install=assert(source:match('^(.*)/scripts/codeoutline/[^/]+$'))
4
4
  package.path=install .. '/scripts/?.lua;' .. package.path
5
5
  local c,u=require('xupgate.common'),require('xutils')
6
6
  local M={}
7
- local function config(options)
7
+ function M.config(options)
8
8
  options=options or {}
9
9
  local build=c.decode_json(c.read(install .. '/build-info.json')) or {}
10
10
  local home=os.getenv('USERPROFILE') or os.getenv('HOME')
@@ -40,7 +40,7 @@ local function config(options)
40
40
  return cfg
41
41
  end
42
42
  function M.run(action,options)
43
- local api=require('xupgate.client').open(config(options))
43
+ local api=require('xupgate.client').open(M.config(options))
44
44
  local function selected()
45
45
  local ok,current=pcall(api.current)
46
46
  if not ok then io.stderr:write('codeoutline: installed update invalid; using initial version\n')end
@@ -48,7 +48,6 @@ function M.run(action,options)
48
48
  end
49
49
  local function finish(err,result)
50
50
  if action=='select' then
51
- if err then io.stderr:write('codeoutline: update unavailable; using local version\n')end
52
51
  io.write(selected(),'\n');io.stdout:flush();xthread.stop(0)
53
52
  else
54
53
  io.write(assert(u.json_pack({ok=not err,error=err,result=result})),'\n');io.stdout:flush();xthread.stop(err and 1 or 0)
@@ -56,7 +55,8 @@ function M.run(action,options)
56
55
  end
57
56
  return {__init=function()
58
57
  assert(xnet.init());xtimer.init(16)
59
- if action=='select' and os.getenv('CODEOUTLINE_AUTO_UPDATE')~='1' then finish(nil)
58
+ -- Selection is local only; serve updates in its background thread.
59
+ if action=='select' then finish(nil)
60
60
  elseif action=='rollback' then
61
61
  local ok,result=pcall(api.rollback)
62
62
  if not ok and tostring(result):find('no previous version',1,true)then ok,result=pcall(api.use_initial)end
@@ -1 +1 @@
1
- return '0.1.3'
1
+ return '0.1.4'