Skip to content

Commit

Permalink
fix(server-core): Handle schemaPath default value correctly everywher…
Browse files Browse the repository at this point in the history
…e (refix) (#8152)
  • Loading branch information
ovr committed Apr 15, 2024
1 parent d9ec7f5 commit 678f17f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 137 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
- 'packages/cubejs-base-driver/**'
- 'packages/cubejs-query-orchestrator/**'
- 'packages/cubejs-schema-compiler/**'
- 'packages/cubejs-backend-shared/**'
- 'packages/cubejs-server-core/**'
# drivers
- 'packages/cubejs-athena-driver/**'
- 'packages/cubejs-bigquery-driver/**'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/drivers-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'packages/cubejs-testing-drivers/**'
- 'packages/cubejs-testing-shared/**'
- 'packages/cubejs-query-orchestrator/src/**'
- 'packages/cubejs-backend-shared/**'
- 'packages/cubejs-server-core/**'
- 'packages/cubejs-base-driver/src/**'
- 'packages/cubejs-jdbc-driver/src/**'

Expand All @@ -31,6 +33,8 @@ on:
- 'packages/cubejs-testing-drivers/**'
- 'packages/cubejs-testing-shared/**'
- 'packages/cubejs-query-orchestrator/src/**'
- 'packages/cubejs-backend-shared/**'
- 'packages/cubejs-server-core/**'
- 'packages/cubejs-base-driver/src/**'
- 'packages/cubejs-jdbc-driver/src/**'

Expand Down
10 changes: 4 additions & 6 deletions packages/cubejs-server-core/src/core/DevServer.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export type ServerCoreInitializedOptions = Required<
'telemetry' |
'dashboardAppPath' |
'dashboardAppPort' |
'schemaPath' |
'driverFactory' |
'dialectFactory' |
'externalDriverFactory' |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getComposePath(type: string, isLocal: boolean): [path: string, f
const volumes = [
'./cube.js:/cube/conf/cube.js',
'./package.json:/cube/conf/package.json',
'./schema/ecommerce.yaml:/cube/conf/schema/ecommerce.yaml',
'./model/ecommerce.yaml:/cube/conf/model/ecommerce.yaml',
];
const compose: any = {
version: '2.2',
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-testing-drivers/src/helpers/getCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function getCore(
source: BaseDriver,
storage: BaseDriver,
): CubejsServerCoreExposed {
const _path = path.resolve(process.cwd(), './.temp/schema/ecommerce.yaml');
const _path = path.resolve(process.cwd(), './.temp/model/ecommerce.yaml');
return new CubejsServerCore({
apiSecret: 'mysupersecret',
// devServer: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getFixtures } from './getFixtures';
* Returns schema yaml file by data source type.
*/
export function getSchemaPath(type: string, suf?: string): [path: string, file: string] {
const _path = path.resolve(process.cwd(), './.temp/schema');
const _path = path.resolve(process.cwd(), './.temp/model');
const _file = 'ecommerce.yaml';
const { tables, preAggregations } = getFixtures(type);
const _content = JSON.parse(fs.readFileSync(
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-testing-drivers/src/helpers/getTempPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export function getTempPath(): void {
fs.rmdirSync(_temp, { recursive: true });
}
fs.mkdirSync(_temp);
fs.mkdirSync(path.resolve(_temp, './schema'));
fs.mkdirSync(path.resolve(_temp, './model'));
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export async function runEnvironment(
compose.withStartupTimeout((isCI() ? 60 : 30) * 1000);
compose.withEnvironment({
CUBEJS_TELEMETRY: 'false',
CUBEJS_SCHEMA_PATH: 'schema'
});

const _path = `${path.resolve(process.cwd(), `./fixtures/${type}.env`)}`;
Expand Down
125 changes: 0 additions & 125 deletions packages/cubejs-testing-drivers/src/types/Core.ts

This file was deleted.

0 comments on commit 678f17f

Please sign in to comment.