@@ -13,6 +13,9 @@ export type Template = {
1313 devDependencies ?: string [ ] ,
1414} ;
1515
16+ /**
17+ * @deprecated
18+ */
1619const indexJs = `const CubejsServer = require('@cubejs-backend/server');
1720
1821const server = new CubejsServer();
@@ -25,6 +28,9 @@ server.listen().then(({ version, port }) => {
2528});
2629` ;
2730
31+ /**
32+ * @deprecated
33+ */
2834const handlerJs = `module.exports = require('@cubejs-backend/serverless');
2935` ;
3036
@@ -75,6 +81,9 @@ node_modules
7581upstream
7682` ;
7783
84+ /**
85+ * @deprecated
86+ */
7887const serverlessYml = env => `service: ${ env . projectName }
7988
8089provider:
@@ -141,6 +150,9 @@ plugins:
141150 - serverless-express
142151` ;
143152
153+ /**
154+ * @deprecated
155+ */
144156const serverlessGoogleYml = env => `service: ${ env . projectName } # NOTE: Don't put the word "google" in here
145157
146158provider:
@@ -192,20 +204,20 @@ functions:
192204 resource: "projects/\${self:provider.project}/topics/\${self:service.name}-\${self:provider.stage}-process"
193205` ;
194206
195- const ordersJs = `cube(\`Orders \`, {
207+ const ordersJs = `cube(\`orders \`, {
196208 sql: \`
197- select 1 as id, 100 as amount, 'new' status
209+ SELECT 1 AS id, 100 AS amount, 'new' status
198210 UNION ALL
199- select 2 as id, 200 as amount, 'new' status
211+ SELECT 2 AS id, 200 AS amount, 'new' status
200212 UNION ALL
201- select 3 as id, 300 as amount, 'processed' status
213+ SELECT 3 AS id, 300 AS amount, 'processed' status
202214 UNION ALL
203- select 4 as id, 500 as amount, 'processed' status
215+ SELECT 4 AS id, 500 AS amount, 'processed' status
204216 UNION ALL
205- select 5 as id, 600 as amount, 'shipped' status
217+ SELECT 5 AS id, 600 AS amount, 'shipped' status
206218 \`,
207219
208- preAggregations : {
220+ pre_aggregations : {
209221 // Pre-aggregation definitions go here
210222 // Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
211223 },
@@ -215,7 +227,7 @@ const ordersJs = `cube(\`Orders\`, {
215227 type: \`count\`
216228 },
217229
218- totalAmount : {
230+ total_amount : {
219231 sql: \`amount\`,
220232 type: \`sum\`
221233 }
@@ -230,6 +242,37 @@ const ordersJs = `cube(\`Orders\`, {
230242});
231243` ;
232244
245+ const ordersYml = `cubes:
246+ - name: orders
247+ sql: >
248+ SELECT 1 AS id, 100 AS amount, 'new' status
249+ UNION ALL
250+ SELECT 2 AS id, 200 AS amount, 'new' status
251+ UNION ALL
252+ SELECT 3 AS id, 300 AS amount, 'processed' status
253+ UNION ALL
254+ SELECT 4 AS id, 500 AS amount, 'processed' status
255+ UNION ALL
256+ SELECT 5 AS id, 600 AS amount, 'shipped' status
257+
258+ # Pre-aggregation definitions go here
259+ # Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
260+ # pre_aggregations:
261+
262+ measures:
263+ - name: count
264+ type: count
265+
266+ - name: total_amount
267+ sql: amount
268+ type: sum
269+
270+ dimensions:
271+ - name: status
272+ sql: status
273+ type: string
274+ ` ;
275+
233276const cubeJs = `// Cube configuration options: https://cube.dev/docs/config
234277/** @type{ import('@cubejs-backend/server-core').CreateOptions } */
235278module.exports = {
@@ -255,6 +298,18 @@ services:
255298` ;
256299
257300const templates : Record < string , Template > = {
301+ 'docker-js' : {
302+ scripts : {
303+ dev : 'cubejs-server' ,
304+ } ,
305+ files : {
306+ 'cube.js' : ( ) => cubeJs ,
307+ 'docker-compose.yml' : dockerCompose ,
308+ '.env' : dotEnv ,
309+ '.gitignore' : ( ) => gitIgnore ,
310+ 'model/cubes/orders.js' : ( ) => ordersJs
311+ }
312+ } ,
258313 docker : {
259314 scripts : {
260315 dev : 'cubejs-server' ,
@@ -264,7 +319,7 @@ const templates: Record<string, Template> = {
264319 'docker-compose.yml' : dockerCompose ,
265320 '.env' : dotEnv ,
266321 '.gitignore' : ( ) => gitIgnore ,
267- 'schema/Orders.js ' : ( ) => ordersJs
322+ 'model/cubes/orders.yml ' : ( ) => ordersYml
268323 }
269324 } ,
270325 express : {
@@ -275,7 +330,7 @@ const templates: Record<string, Template> = {
275330 'index.js' : ( ) => indexJs ,
276331 '.env' : dotEnv ,
277332 '.gitignore' : ( ) => gitIgnore ,
278- 'schema/Orders .js' : ( ) => ordersJs
333+ 'model/cubes/orders .js' : ( ) => ordersJs
279334 }
280335 } ,
281336 serverless : {
@@ -287,7 +342,7 @@ const templates: Record<string, Template> = {
287342 'serverless.yml' : serverlessYml ,
288343 '.env' : dotEnv ,
289344 '.gitignore' : ( ) => gitIgnore ,
290- 'schema/Orders .js' : ( ) => ordersJs
345+ 'model/cubes/orders .js' : ( ) => ordersJs
291346 } ,
292347 dependencies : [ '@cubejs-backend/serverless' , '@cubejs-backend/serverless-aws' ]
293348 } ,
0 commit comments