@lotics/cli 0.31.0 → 0.33.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/README.md +27 -0
- package/dist/{src/app_commands.js → app_commands.js} +35 -0
- package/dist/cli.js +673 -0
- package/dist/{src/dev → dev}/wrapper_page.js +33 -5
- package/dist/docx.d.ts +2 -0
- package/dist/docx.js +341 -0
- package/dist/docx.test.d.ts +1 -0
- package/dist/docx.test.js +145 -0
- package/dist/file_command_io.d.ts +12 -0
- package/dist/file_command_io.js +34 -0
- package/dist/src/cli.js +46757 -500
- package/dist/{src/starter_template.d.ts → starter_template.d.ts} +16 -0
- package/dist/{src/starter_template.js → starter_template.js} +25 -2
- package/dist/starter_template.test.d.ts +1 -0
- package/dist/starter_template.test.js +32 -0
- package/dist/xlsx.d.ts +2 -0
- package/dist/xlsx.js +489 -0
- package/dist/xlsx.test.d.ts +1 -0
- package/dist/xlsx.test.js +131 -0
- package/package.json +6 -2
- /package/dist/{src/app_commands.d.ts → app_commands.d.ts} +0 -0
- /package/dist/{src/app_commands.test.d.ts → app_commands.test.d.ts} +0 -0
- /package/dist/{src/app_commands.test.js → app_commands.test.js} +0 -0
- /package/dist/{src/args.d.ts → args.d.ts} +0 -0
- /package/dist/{src/args.js → args.js} +0 -0
- /package/dist/{src/args.test.d.ts → args.test.d.ts} +0 -0
- /package/dist/{src/args.test.js → args.test.js} +0 -0
- /package/dist/{src/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{src/client.d.ts → client.d.ts} +0 -0
- /package/dist/{src/client.js → client.js} +0 -0
- /package/dist/{src/config.d.ts → config.d.ts} +0 -0
- /package/dist/{src/config.js → config.js} +0 -0
- /package/dist/{src/config.test.d.ts → config.test.d.ts} +0 -0
- /package/dist/{src/config.test.js → config.test.js} +0 -0
- /package/dist/{src/dev → dev}/rpc_handler.d.ts +0 -0
- /package/dist/{src/dev → dev}/rpc_handler.js +0 -0
- /package/dist/{src/dev → dev}/server.d.ts +0 -0
- /package/dist/{src/dev → dev}/server.js +0 -0
- /package/dist/{src/dev → dev}/wrapper_page.d.ts +0 -0
- /package/dist/{src/generate_app_queries_dts.d.ts → generate_app_queries_dts.d.ts} +0 -0
- /package/dist/{src/generate_app_queries_dts.js → generate_app_queries_dts.js} +0 -0
- /package/dist/{src/generate_app_workflows_dts.d.ts → generate_app_workflows_dts.d.ts} +0 -0
- /package/dist/{src/generate_app_workflows_dts.js → generate_app_workflows_dts.js} +0 -0
- /package/dist/{src/version.d.ts → version.d.ts} +0 -0
- /package/dist/{src/version.js → version.js} +0 -0
package/README.md
CHANGED
|
@@ -101,6 +101,33 @@ lotics download <file_id> -o ./reports/
|
|
|
101
101
|
LOTICS_API_KEY=ltk_... lotics run query_tables '{}'
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
## Local .xlsx and .docx authoring
|
|
105
|
+
|
|
106
|
+
The CLI bundles Lotics's own xlsx and docx engines so you can read, write, and edit files on your local filesystem without installing `xlsx` / `exceljs` / `docx` from npm. Prefer these over third-party libraries — they round-trip faithfully with the Lotics editor, template engine, and formula engine.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# .xlsx
|
|
110
|
+
lotics xlsx read ./report.xlsx # → JSON of sheets, cells, merges
|
|
111
|
+
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1","cells":{"A1":"Hi","B1":42}}]}'
|
|
112
|
+
lotics xlsx set-cell ./report.xlsx 'Sheet1!A1' '=SUM(B:B)'
|
|
113
|
+
lotics xlsx add-sheet ./report.xlsx 'Summary'
|
|
114
|
+
lotics xlsx merge ./report.xlsx 'Sheet1!A1:C1'
|
|
115
|
+
lotics xlsx insert-rows ./report.xlsx Sheet1 5 3
|
|
116
|
+
lotics xlsx batch ./report.xlsx '[{"op":"set-cell","sheet":"Sheet1","ref":"A1","value":"Hi"}, {"op":"merge","sheet":"Sheet1","range":"A1:B1"}]'
|
|
117
|
+
|
|
118
|
+
# .docx
|
|
119
|
+
lotics docx read ./report.docx # → JSON of blocks with text + style
|
|
120
|
+
lotics docx write ./out.docx '{"blocks":[{"kind":"paragraph","text":"Title","style":"Heading1"}]}'
|
|
121
|
+
lotics docx append-paragraph ./report.docx 'New paragraph' --style=Heading2
|
|
122
|
+
lotics docx insert-paragraph ./report.docx 'Front matter' --at=0
|
|
123
|
+
lotics docx replace-text ./report.docx '{{name}}' 'Acme Inc.'
|
|
124
|
+
lotics docx batch ./report.docx '[{"op":"append-paragraph","text":"A","style":"Heading1"},{"op":"replace-text","search":"x","replace":"y"}]'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Edits mutate the file in place via an atomic temp-file + rename. Unknown OOXML constructs (tables, SmartArt, custom XML) round-trip verbatim — they show up in `read` as `opaque_block` entries.
|
|
128
|
+
|
|
129
|
+
Run `lotics xlsx` or `lotics docx` with no subcommand for the full list.
|
|
130
|
+
|
|
104
131
|
## SDK
|
|
105
132
|
|
|
106
133
|
```typescript
|
|
@@ -19,6 +19,32 @@ import { buildStarterTemplate } from "./starter_template.js";
|
|
|
19
19
|
import { startDevServer, openBrowser } from "./dev/server.js";
|
|
20
20
|
import { generateAppWorkflowsDts } from "./generate_app_workflows_dts.js";
|
|
21
21
|
import { generateAppQueriesDts } from "./generate_app_queries_dts.js";
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the latest published version of a package from the npm registry.
|
|
24
|
+
* Returns null on any failure (network error, 404, malformed payload) so
|
|
25
|
+
* callers can fall back to a static pin rather than crashing `app create`.
|
|
26
|
+
*
|
|
27
|
+
* 1.5s timeout — npm registry is fast when reachable; the fallback is fine
|
|
28
|
+
* the rare times it isn't, and we don't want to block scaffold on a hang.
|
|
29
|
+
*/
|
|
30
|
+
async function fetchLatestNpmVersion(packageName) {
|
|
31
|
+
try {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const timeout = setTimeout(() => controller.abort(), 1500);
|
|
34
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
35
|
+
signal: controller.signal,
|
|
36
|
+
headers: { accept: "application/json" },
|
|
37
|
+
});
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
if (!response.ok)
|
|
40
|
+
return null;
|
|
41
|
+
const body = (await response.json());
|
|
42
|
+
return typeof body.version === "string" ? body.version : null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
22
48
|
/** Run `tar` and resolve when it exits cleanly. Throws with stderr on failure. */
|
|
23
49
|
function runTar(args, cwd) {
|
|
24
50
|
return new Promise((resolve, reject) => {
|
|
@@ -148,11 +174,20 @@ export async function appCreate(client, args) {
|
|
|
148
174
|
// Server-side row first — if this fails, no local files have been touched.
|
|
149
175
|
const app = await client.createApp({ name: args.name });
|
|
150
176
|
console.error(`Created app: ${app.name} (${app.id})`);
|
|
177
|
+
// Resolve latest versions in parallel; null falls back to the static pin
|
|
178
|
+
// baked into the starter template. Lookups time out at 1.5s so an offline
|
|
179
|
+
// create still succeeds (with the fallback) instead of hanging.
|
|
180
|
+
const [uiLatest, sdkLatest] = await Promise.all([
|
|
181
|
+
fetchLatestNpmVersion("@lotics/ui"),
|
|
182
|
+
fetchLatestNpmVersion("@lotics/app-sdk"),
|
|
183
|
+
]);
|
|
151
184
|
// Scaffold the starter into the target directory.
|
|
152
185
|
const files = buildStarterTemplate({
|
|
153
186
|
app_name: args.name,
|
|
154
187
|
app_id: app.id,
|
|
155
188
|
workspace_id: app.workspace_id,
|
|
189
|
+
ui_version: uiLatest ? `^${uiLatest}` : undefined,
|
|
190
|
+
sdk_version: sdkLatest ? `^${sdkLatest}` : undefined,
|
|
156
191
|
});
|
|
157
192
|
for (const file of files) {
|
|
158
193
|
const fullPath = path.join(targetPath, file.path);
|