Skip to content

Commit

Permalink
fix(server-core): Handle schemaPath default value correctly everywhere (
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Apr 11, 2024
1 parent ee7bcee commit 23bd621
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions packages/cubejs-server-core/src/core/DevServer.ts
Expand Up @@ -161,12 +161,10 @@ export class DevServer {
});
const files = scaffoldingTemplate.generateFilesByTableNames(req.body.tables, { dataSource });

const schemaPath = options.schemaPath || 'schema';

await fs.emptyDir(path.join(schemaPath, 'cubes'));
await fs.emptyDir(path.join(schemaPath, 'views'));
await fs.emptyDir(path.join(options.schemaPath, 'cubes'));
await fs.emptyDir(path.join(options.schemaPath, 'views'));

await fs.writeFile(path.join(schemaPath, 'views', 'example_view.yml'), `# In Cube, views are used to expose slices of your data graph and act as data marts.
await fs.writeFile(path.join(options.schemaPath, 'views', 'example_view.yml'), `# In Cube, views are used to expose slices of your data graph and act as data marts.
# You can control which measures and dimensions are exposed to BIs or data apps,
# as well as the direction of joins between the exposed cubes.
# You can learn more about views in documentation here - https://cube.dev/docs/schema/reference/view
Expand Down Expand Up @@ -195,7 +193,7 @@ export class DevServer {
# prefix: true
# includes:
# - city`);
await Promise.all(files.map(file => fs.writeFile(path.join(schemaPath, 'cubes', file.fileName), file.content)));
await Promise.all(files.map(file => fs.writeFile(path.join(options.schemaPath, 'cubes', file.fileName), file.content)));

res.json({ files });
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-server-core/src/core/OptsHandler.ts
Expand Up @@ -468,7 +468,7 @@ export class OptsHandler {
(this.isDevMode()
? 'dev_pre_aggregations'
: 'prod_pre_aggregations'),
schemaPath: process.env.CUBEJS_SCHEMA_PATH || 'schema',
schemaPath: getEnv('schemaPath'),
scheduledRefreshTimer: getEnv('refreshWorkerMode'),
sqlCache: true,
livePreview: getEnv('livePreview'),
Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-server-core/src/core/types.ts
Expand Up @@ -230,6 +230,7 @@ export type ServerCoreInitializedOptions = Required<
'telemetry' |
'dashboardAppPath' |
'dashboardAppPort' |
'schemaPath' |
'driverFactory' |
'dialectFactory' |
'externalDriverFactory' |
Expand Down

0 comments on commit 23bd621

Please sign in to comment.