@lightdash/cli 1.71.0 → 1.73.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appCodeFiles.d.ts","sourceRoot":"","sources":["../../../src/handlers/apps/appCodeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAChC,MAAM,mBAAmB,CAAC;AAO3B;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAChB,MAAM,WACH,MAAM,gBACD,GAAG,CAAC,MAAM,CAAC,KAC1B,MAcF,CAAC;AAEF,eAAO,MAAM,eAAe,QACnB,MAAM,SACJ,eAAe,EAAE,KACzB,OAAO,CAAC,IAAI,CAsBd,CAAC;AAEF,eAAO,MAAM,iBAAiB,QACrB,MAAM,WACF,cAAc,KACxB,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"appCodeFiles.d.ts","sourceRoot":"","sources":["../../../src/handlers/apps/appCodeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAChC,MAAM,mBAAmB,CAAC;AAO3B;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAChB,MAAM,WACH,MAAM,gBACD,GAAG,CAAC,MAAM,CAAC,KAC1B,MAcF,CAAC;AAEF,eAAO,MAAM,eAAe,QACnB,MAAM,SACJ,eAAe,EAAE,KACzB,OAAO,CAAC,IAAI,CAsBd,CAAC;AAEF,eAAO,MAAM,iBAAiB,QACrB,MAAM,WACF,cAAc,KACxB,OAAO,CAAC,IAAI,CAiBd,CAAC;AAEF,eAAO,MAAM,gBAAgB,QACpB,M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AqBjB,CAAC;AAEF,eAAO,MAAM,mBAAmB,QACvB,MAAM,KACZ,OAAO,CAAC,eAAe,CAYzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAe,MAAM,KAAG,OAAO,CAAC,WAAW,CAYxE,CAAC"}
|
|
@@ -44,8 +44,16 @@ const writeFilesToDir = async (dir, files) => {
|
|
|
44
44
|
};
|
|
45
45
|
exports.writeFilesToDir = writeFilesToDir;
|
|
46
46
|
const writeContextToDir = async (dir, context) => {
|
|
47
|
+
// Server-owned snapshot: clear it so files from a previous download
|
|
48
|
+
// (removed models, parameters, theme assets) don't linger.
|
|
49
|
+
await fs_1.promises.rm(path.join(dir, '.lightdash', 'context'), {
|
|
50
|
+
recursive: true,
|
|
51
|
+
force: true,
|
|
52
|
+
});
|
|
47
53
|
const files = [
|
|
48
54
|
context.semanticLayer,
|
|
55
|
+
// Absent on pre-sharding servers — semanticLayer is then the whole layer.
|
|
56
|
+
...(context.semanticLayerFiles ?? []),
|
|
49
57
|
...(context.parameters ? [context.parameters] : []),
|
|
50
58
|
context.promptHistory,
|
|
51
59
|
...(context.theme.instructions ? [context.theme.instructions] : []),
|
|
@@ -183,6 +183,38 @@ it('writes context files under .lightdash/context and skips null parameters', as
|
|
|
183
183
|
expect(await fs_1.promises.readFile(path.join(dir, '.lightdash/context/theme/instructions.md'), 'utf-8')).toBe('# theme');
|
|
184
184
|
await expect(fs_1.promises.access(path.join(dir, '.lightdash/context/parameters.yml'))).rejects.toThrow();
|
|
185
185
|
});
|
|
186
|
+
it('writes sharded semantic layer files and clears the previous context snapshot', async () => {
|
|
187
|
+
const dir = await fs_1.promises.mkdtemp(path.join(os.tmpdir(), 'ld-ctx-'));
|
|
188
|
+
await fs_1.promises.mkdir(path.join(dir, '.lightdash/context/models'), {
|
|
189
|
+
recursive: true,
|
|
190
|
+
});
|
|
191
|
+
await fs_1.promises.writeFile(path.join(dir, '.lightdash/context/models/deleted_model.yml'), 'models: []');
|
|
192
|
+
await fs_1.promises.writeFile(path.join(dir, '.lightdash/context/parameters.yml'), 'parameters: {}');
|
|
193
|
+
await fs_1.promises.mkdir(path.join(dir, 'src'), { recursive: true });
|
|
194
|
+
await fs_1.promises.writeFile(path.join(dir, 'src/App.tsx'), '// keep');
|
|
195
|
+
await (0, appCodeFiles_1.writeContextToDir)(dir, {
|
|
196
|
+
semanticLayer: {
|
|
197
|
+
path: '.lightdash/context/semantic-layer.yml',
|
|
198
|
+
contentBase64: Buffer.from('# see models/').toString('base64'),
|
|
199
|
+
},
|
|
200
|
+
semanticLayerFiles: [
|
|
201
|
+
{
|
|
202
|
+
path: '.lightdash/context/models/orders.yml',
|
|
203
|
+
contentBase64: Buffer.from('models: []').toString('base64'),
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
parameters: null,
|
|
207
|
+
promptHistory: {
|
|
208
|
+
path: '.lightdash/context/prompt-history.md',
|
|
209
|
+
contentBase64: Buffer.from('# prompts').toString('base64'),
|
|
210
|
+
},
|
|
211
|
+
theme: { instructions: null, assets: [], skippedAssetCount: 0 },
|
|
212
|
+
});
|
|
213
|
+
expect(await fs_1.promises.readFile(path.join(dir, '.lightdash/context/models/orders.yml'), 'utf-8')).toBe('models: []');
|
|
214
|
+
await expect(fs_1.promises.access(path.join(dir, '.lightdash/context/models/deleted_model.yml'))).rejects.toThrow();
|
|
215
|
+
await expect(fs_1.promises.access(path.join(dir, '.lightdash/context/parameters.yml'))).rejects.toThrow();
|
|
216
|
+
expect(await fs_1.promises.readFile(path.join(dir, 'src/App.tsx'), 'utf-8')).toBe('// keep');
|
|
217
|
+
});
|
|
186
218
|
describe('appFolderName', () => {
|
|
187
219
|
it('returns the slugified name when no collision', () => {
|
|
188
220
|
const taken = new Set();
|
|
@@ -57,7 +57,7 @@ You are editing a Lightdash **data app** that was created or downloaded with the
|
|
|
57
57
|
|
|
58
58
|
`.lightdash/context/` holds a point-in-time snapshot of the source project:
|
|
59
59
|
|
|
60
|
-
- `semantic
|
|
60
|
+
- `models/` — the semantic layer, one YAML file per model: the real tables/dimensions/metrics you can query. Use these exact names. Start with `models/_index.md`, then read only the model files you need. (Apps downloaded with an older CLI carry the whole semantic layer in `semantic-layer.yml` instead and have no `models/`.)
|
|
61
61
|
- `parameters.yml` — project-wide parameters (if any).
|
|
62
62
|
- `prompt-history.md` — the prompts used to generate each version.
|
|
63
63
|
- `theme/` — styling instructions and assets.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.73.0",
|
|
4
4
|
"description": "Lightdash CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"unique-names-generator": "4.7.1",
|
|
42
42
|
"uuid": "11.1.1",
|
|
43
43
|
"yaml": "2.8.3",
|
|
44
|
-
"@lightdash/common": "1.
|
|
45
|
-
"@lightdash/warehouses": "1.
|
|
44
|
+
"@lightdash/common": "1.73.0",
|
|
45
|
+
"@lightdash/warehouses": "1.73.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/inquirer": "8.2.4",
|