pinstripe 0.10.0 → 0.11.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/lib/base.js +7 -0
- package/lib/base.test.js +13 -29
- package/lib/client.js +49 -0
- package/lib/command.js +20 -0
- package/lib/commands/_importer.js +2 -0
- package/lib/commands/create_database.js +1 -3
- package/lib/commands/drop_database.js +1 -3
- package/lib/commands/generate_command.js +10 -8
- package/lib/commands/generate_migration.js +10 -8
- package/lib/commands/generate_model.js +10 -8
- package/lib/commands/generate_project.js +2 -11
- package/lib/commands/generate_service.js +10 -8
- package/lib/commands/generate_static_site.js +79 -0
- package/lib/commands/generate_view.js +6 -8
- package/lib/commands/generate_widget.js +15 -9
- package/lib/commands/init_database.js +2 -4
- package/lib/commands/list_commands.js +2 -3
- package/lib/commands/list_migrations.js +2 -3
- package/lib/commands/list_models.js +2 -3
- package/lib/commands/list_services.js +2 -3
- package/lib/commands/list_views.js +2 -3
- package/lib/commands/list_widgets.js +3 -4
- package/lib/commands/migrate_database.js +1 -3
- package/lib/commands/reset_database.js +2 -4
- package/lib/commands/seed_database.js +2 -4
- package/lib/commands/start_console.js +2 -3
- package/lib/commands/start_server.js +3 -9
- package/lib/constants.js +0 -9
- package/lib/database/column.js +3 -1
- package/lib/database/constants.js +20 -0
- package/lib/database/migration.js +20 -0
- package/lib/database/row.js +55 -4
- package/lib/database/sql.js +4 -3
- package/lib/database/table.js +49 -15
- package/lib/database/union.js +29 -8
- package/lib/database.js +15 -11
- package/lib/html.js +1 -1
- package/lib/import_all.js +13 -9
- package/lib/index.js +6 -6
- package/lib/migrations/1627976184_create_user.js +2 -4
- package/lib/migrations/1628057822_create_session.js +2 -4
- package/lib/migrations/_importer.js +2 -0
- package/lib/models/_importer.js +2 -0
- package/lib/models/session.js +2 -4
- package/lib/models/user.js +4 -5
- package/lib/node_wrapper.js +185 -13
- package/lib/overload.js +1 -0
- package/lib/service_factory.js +40 -0
- package/lib/services/_importer.js +2 -0
- package/lib/services/args.js +1 -4
- package/lib/services/cli_utils.js +2 -4
- package/lib/services/config.js +2 -4
- package/lib/services/cookies.js +2 -4
- package/lib/services/database.js +2 -5
- package/lib/services/fetch.js +18 -8
- package/lib/services/fork_environment.js +2 -4
- package/lib/services/fs_builder.js +2 -3
- package/lib/services/params.js +1 -4
- package/lib/services/project.js +1 -3
- package/lib/services/read_file.js +6 -0
- package/lib/services/render_file.js +4 -7
- package/lib/services/render_form.js +60 -15
- package/lib/services/render_html.js +2 -4
- package/lib/services/render_list.js +58 -0
- package/lib/services/render_markdown.js +6 -0
- package/lib/services/render_table.js +68 -0
- package/lib/services/render_view.js +2 -4
- package/lib/services/reset_environment.js +2 -4
- package/lib/services/run_command.js +2 -4
- package/lib/services/session.js +2 -4
- package/lib/services/view.js +1 -4
- package/lib/url.js +12 -4
- package/lib/url.test.js +5 -1
- package/lib/view.js +84 -0
- package/lib/views/_importer.js +2 -0
- package/lib/views/_layout.js +2 -4
- package/lib/{static → views}/bundle.css +76 -0
- package/lib/views/bundle.css.map +1 -0
- package/lib/views/bundle.js +7 -32
- package/lib/views/sign_in.js +5 -4
- package/lib/views/sign_out.js +5 -5
- package/lib/virtual_node.js +15 -49
- package/lib/widgets/_importer.js +2 -0
- package/lib/widgets/frame.client.js +45 -5
- package/lib/widgets/internal/actions.client.js +51 -0
- package/lib/widgets/{document.client.js → internal/document.client.js} +15 -8
- package/lib/widgets/internal/markdown_editor.client.js +26 -0
- package/lib/widgets/internal/overlay.client.js +43 -0
- package/lib/widgets/{document → internal}/progress_bar.client.js +8 -3
- package/lib/widgets/trigger.client.js +20 -0
- package/package.json +6 -4
- package/pinstripe.scss +1 -1
- package/lib/scss/index.scss +0 -2
- package/lib/services/render_script.js +0 -14
- package/lib/static/bundle.css.map +0 -1
- package/lib/widgets/anchor.client.js +0 -54
- package/lib/widgets/document/style.client.js +0 -49
- package/lib/widgets/form.client.js +0 -60
- package/lib/widgets/input.client.js +0 -26
- package/lib/widgets/overlay.client.js +0 -29
- package/lib/widgets/script.client.js +0 -9
package/lib/base.js
CHANGED
package/lib/base.test.js
CHANGED
|
@@ -65,32 +65,16 @@ test(`Base - if the __call has been defined getting/setting still works`, async
|
|
|
65
65
|
}).new();
|
|
66
66
|
|
|
67
67
|
expect(fixture.foo).toBe("bar");
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// test(`Base - abstract classes can be included in other classes`, () => {
|
|
83
|
-
// const Foo = Base.extend().include({
|
|
84
|
-
// abstract: true,
|
|
85
|
-
|
|
86
|
-
// fruit(){
|
|
87
|
-
// return 'apple';
|
|
88
|
-
// }
|
|
89
|
-
// });
|
|
90
|
-
// const Bar = Base.extend().include(Foo);
|
|
91
|
-
// const Baz = Base.extend().include(Bar);
|
|
92
|
-
|
|
93
|
-
// expect(typeof Foo.new().fruit).toBe('undefined');
|
|
94
|
-
// expect(Bar.new().fruit()).toBe('apple');
|
|
95
|
-
// expect(Baz.new().fruit()).toBe('apple');
|
|
96
|
-
// });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test(`Base - can produce dynamic keys`, () => {
|
|
71
|
+
const fixture = Base.extend().include({
|
|
72
|
+
baz: 'hello world',
|
|
73
|
+
|
|
74
|
+
__keys(){
|
|
75
|
+
return ['foo', 'bar'];
|
|
76
|
+
}
|
|
77
|
+
}).new();
|
|
78
|
+
|
|
79
|
+
expect(Object.keys(fixture)).toEqual(['foo', 'bar']);
|
|
80
|
+
});
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { readFile } from 'fs';
|
|
4
|
+
import { Volume as MemFs } from 'memfs';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import { Union as UnionFs } from 'unionfs';
|
|
7
|
+
|
|
8
|
+
import { Base } from './base.js';
|
|
9
|
+
import { overload } from './overload.js';
|
|
10
|
+
|
|
11
|
+
export const client = Base.extend().include({
|
|
12
|
+
initialize(){
|
|
13
|
+
this.files = {};
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
addFile: overload({
|
|
17
|
+
['string, function'](filePath, fn){
|
|
18
|
+
this.files[filePath] = fn;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
string(filePath){
|
|
22
|
+
this.addFile(filePath, async () => {
|
|
23
|
+
return (await promisify(readFile)(filePath)).toString();
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
async createFs(entryFilePath){
|
|
29
|
+
const files = {};
|
|
30
|
+
const filePaths = Object.keys(this.files);
|
|
31
|
+
while(filePaths.length){
|
|
32
|
+
const filePath = filePaths.pop();
|
|
33
|
+
const data = await this.files[filePath]();
|
|
34
|
+
files[filePath] = data.replace(/(.*)\/\/\s*pinstripe-if-client:\s*(.*)/g, '$2 // pinstripe-if-server: $1');
|
|
35
|
+
}
|
|
36
|
+
return new UnionFs().use(fs).use(new MemFs.fromJSON({
|
|
37
|
+
...files,
|
|
38
|
+
[entryFilePath]: `
|
|
39
|
+
${
|
|
40
|
+
Object.keys(this.files).filter(filePath => filePath.match(/\/[^\.\/]+(\.client\.js)$/)).map(filePath => `
|
|
41
|
+
import ${JSON.stringify(filePath)};
|
|
42
|
+
`).join('\n')
|
|
43
|
+
}
|
|
44
|
+
`
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}).new();
|
|
48
|
+
|
|
49
|
+
export const addFileToClient = (...args) => client.addFile(...args);
|
package/lib/command.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Registrable } from './registrable.js';
|
|
|
4
4
|
import { dasherize } from './inflector.js';
|
|
5
5
|
import { overload } from './overload.js';
|
|
6
6
|
import { thatify } from './thatify.js';
|
|
7
|
+
import { addFileToClient } from './client.js';
|
|
7
8
|
|
|
8
9
|
export const Command = Base.extend().include({
|
|
9
10
|
meta(){
|
|
@@ -47,3 +48,22 @@ export const defineCommand = overload({
|
|
|
47
48
|
defineCommand(name, { run: thatify(fn) });
|
|
48
49
|
}
|
|
49
50
|
});
|
|
51
|
+
|
|
52
|
+
export const commandImporter = dirPath => {
|
|
53
|
+
return async filePath => {
|
|
54
|
+
const relativeFilePath = filePath.substr(dirPath.length).replace(/^\//, '');
|
|
55
|
+
|
|
56
|
+
if(filePath.match(/\.js$/)){
|
|
57
|
+
const relativeFilePathWithoutExtension = relativeFilePath.replace(/\.[^/]+$/, '');
|
|
58
|
+
if(relativeFilePathWithoutExtension == '_importer'){
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
addFileToClient(filePath);
|
|
62
|
+
const definition = await ( await import(filePath) ).default;
|
|
63
|
+
if(definition !== undefined){
|
|
64
|
+
defineCommand(relativeFilePathWithoutExtension, definition);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-command', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent },
|
|
7
5
|
snakeify, dasherize
|
|
@@ -14,17 +12,21 @@ defineCommand('generate-command', async ({
|
|
|
14
12
|
|
|
15
13
|
await inProjectRootDir(async () => {
|
|
16
14
|
|
|
17
|
-
await generateFile(`lib/commands
|
|
15
|
+
await generateFile(`lib/commands/_importer.js`, { skipIfExists: true }, () => {
|
|
16
|
+
line();
|
|
17
|
+
line(`export { commandImporter as default } from 'pinstripe';`);
|
|
18
18
|
line();
|
|
19
|
-
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await generateFile(`lib/commands/${name}.js`, () => {
|
|
20
22
|
line();
|
|
21
|
-
line(`
|
|
23
|
+
line(`export default () => {`);
|
|
22
24
|
indent(() => {
|
|
23
25
|
line(`console.log('${dasherize(name)} command coming soon!')`);
|
|
24
26
|
});
|
|
25
|
-
line('}
|
|
27
|
+
line('};');
|
|
26
28
|
line();
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
});
|
|
30
|
-
}
|
|
32
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-migration', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg, extractFields, extractOptions },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent },
|
|
7
5
|
snakeify
|
|
@@ -22,11 +20,15 @@ defineCommand('generate-migration', async ({
|
|
|
22
20
|
|
|
23
21
|
await inProjectRootDir(async () => {
|
|
24
22
|
|
|
25
|
-
await generateFile(`lib/migrations
|
|
23
|
+
await generateFile(`lib/migrations/_importer.js`, { skipIfExists: true }, () => {
|
|
24
|
+
line();
|
|
25
|
+
line(`export { migrationImporter as default } from 'pinstripe';`);
|
|
26
26
|
line();
|
|
27
|
-
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
await generateFile(`lib/migrations/${name}.js`, () => {
|
|
28
30
|
line();
|
|
29
|
-
line(`
|
|
31
|
+
line(`export default async ({ database }) => {`);
|
|
30
32
|
indent(() => {
|
|
31
33
|
line();
|
|
32
34
|
if(table && fields.length){
|
|
@@ -36,8 +38,8 @@ defineCommand('generate-migration', async ({
|
|
|
36
38
|
line();
|
|
37
39
|
}
|
|
38
40
|
})
|
|
39
|
-
line('}
|
|
41
|
+
line('};');
|
|
40
42
|
line();
|
|
41
43
|
});
|
|
42
44
|
});
|
|
43
|
-
}
|
|
45
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-model', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg, extractFields },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent },
|
|
7
5
|
snakeify, pluralize, camelize,
|
|
@@ -26,17 +24,21 @@ defineCommand('generate-model', async ({
|
|
|
26
24
|
|
|
27
25
|
await inProjectRootDir(async () => {
|
|
28
26
|
|
|
29
|
-
await generateFile(`lib/models
|
|
27
|
+
await generateFile(`lib/models/_importer.js`, { skipIfExists: true }, () => {
|
|
28
|
+
line();
|
|
29
|
+
line(`export { modelImporter as default } from 'pinstripe';`);
|
|
30
30
|
line();
|
|
31
|
-
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await generateFile(`lib/models/${name}.js`, () => {
|
|
32
34
|
line();
|
|
33
|
-
line(`
|
|
35
|
+
line(`export default {`);
|
|
34
36
|
indent(() => {
|
|
35
37
|
line();
|
|
36
38
|
});
|
|
37
|
-
line('}
|
|
39
|
+
line('};');
|
|
38
40
|
line();
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
});
|
|
42
|
-
}
|
|
44
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { spawnSync } from 'child_process';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
defineCommand('generate-project', async ({
|
|
4
|
+
export default async ({
|
|
7
5
|
cliUtils: { extractArg, extractOptions },
|
|
8
6
|
fsBuilder: { generateDir, generateFile, line, indent, echo }
|
|
9
7
|
}) => {
|
|
@@ -43,16 +41,9 @@ defineCommand('generate-project', async ({
|
|
|
43
41
|
line();
|
|
44
42
|
});
|
|
45
43
|
|
|
46
|
-
await generateFile(`lib/web/_importer.js`, () => {
|
|
47
|
-
line();
|
|
48
|
-
line(`export { webImporter as default } from 'pinstripe';`);
|
|
49
|
-
line();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
|
|
53
44
|
spawnSync('yarn', [ 'add', ...dependencies ], {
|
|
54
45
|
stdio: 'inherit'
|
|
55
46
|
});
|
|
56
47
|
|
|
57
48
|
});
|
|
58
|
-
}
|
|
49
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-service', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent },
|
|
7
5
|
snakeify, camelize
|
|
@@ -14,17 +12,21 @@ defineCommand('generate-service', async ({
|
|
|
14
12
|
|
|
15
13
|
await inProjectRootDir(async () => {
|
|
16
14
|
|
|
17
|
-
await generateFile(`lib/services
|
|
15
|
+
await generateFile(`lib/services/_importer.js`, { skipIfExists: true }, () => {
|
|
16
|
+
line();
|
|
17
|
+
line(`export { serviceImporter as default } from 'pinstripe';`);
|
|
18
18
|
line();
|
|
19
|
-
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await generateFile(`lib/services/${snakeify(name)}.js`, () => {
|
|
20
22
|
line();
|
|
21
|
-
line(`
|
|
23
|
+
line(`export default () => {`);
|
|
22
24
|
indent(() => {
|
|
23
25
|
line(`return 'Example ${camelize(name)} service'`);
|
|
24
26
|
});
|
|
25
|
-
line('}
|
|
27
|
+
line('};');
|
|
26
28
|
line();
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
});
|
|
30
|
-
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
import { VirtualNode } from '../virtual_node.js';
|
|
3
|
+
import { Url } from '../url.js';
|
|
4
|
+
import { View } from '../view.js';
|
|
5
|
+
import { default as mimeTypes } from 'mime-types';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
|
|
9
|
+
async run(){
|
|
10
|
+
this.pages = {};
|
|
11
|
+
const paths = Object.keys(View.classes).filter(path => !path.match(/(^|\/)_/)).map(path => {
|
|
12
|
+
return `/${path.replace(/(^|\/)index$/, '')}`.replace(/^\/+/, '/');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
while(paths.length){
|
|
16
|
+
await this.crawlPage({ _path: paths.shift() });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const pages = Object.values(this.pages).filter(page => page.status == 200 && Object.keys(page.params).length == 1);
|
|
20
|
+
const { inProjectRootDir, generateDir, generateFile, echo } = this.fsBuilder;
|
|
21
|
+
|
|
22
|
+
await inProjectRootDir(async () => {
|
|
23
|
+
await generateDir('build/static', async () => {
|
|
24
|
+
while(pages.length){
|
|
25
|
+
const { params, headers } = pages.shift();
|
|
26
|
+
const contentType = headers['content-type'];
|
|
27
|
+
|
|
28
|
+
const path = params._path;
|
|
29
|
+
let filePath = path.replace(/^\//, '');
|
|
30
|
+
if(filePath.match(/(^|\/)$/)){
|
|
31
|
+
filePath = `${filePath}index`;
|
|
32
|
+
}
|
|
33
|
+
if(!filePath.match(/[^/]+\.[^/]+$/)){
|
|
34
|
+
filePath = `${filePath}.${mimeTypes.extension(contentType)}`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const data = (await this.fetch({ _path: path }))[2];
|
|
38
|
+
|
|
39
|
+
await generateFile(filePath, () => {
|
|
40
|
+
echo(data.join(''));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
async crawlPage(params){
|
|
48
|
+
const hash = JSON.stringify(params);
|
|
49
|
+
if(this.pages[hash]) return;
|
|
50
|
+
const page = { params };
|
|
51
|
+
this.pages[hash] = page;
|
|
52
|
+
const [ status, headers, data ] = await this.fetch(params);
|
|
53
|
+
page.status = status;
|
|
54
|
+
page.headers = headers;
|
|
55
|
+
if(status != 200 || headers['content-type'] != 'text/html') return;
|
|
56
|
+
const html = data.join('');
|
|
57
|
+
const virtualDom = VirtualNode.fromString(html);
|
|
58
|
+
const urls = this.extractUrls(virtualDom);
|
|
59
|
+
while(urls.length){
|
|
60
|
+
const url = urls.shift();
|
|
61
|
+
await this.crawlPage({ ...url.params, _path: url.path });
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
extractUrls(virtualDom){
|
|
66
|
+
const out = [];
|
|
67
|
+
virtualDom.traverse(({ attributes }) => {
|
|
68
|
+
['src', 'href'].forEach(name => {
|
|
69
|
+
const value = attributes[name];
|
|
70
|
+
if(!value) return;
|
|
71
|
+
const url = Url.fromString(value, 'http://localhost/');
|
|
72
|
+
if(url.host != 'localhost') return;
|
|
73
|
+
out.push(url);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-view', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent }
|
|
7
5
|
}) => {
|
|
@@ -16,14 +14,14 @@ defineCommand('generate-view', async ({
|
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
await inProjectRootDir(async () => {
|
|
19
|
-
|
|
20
|
-
await generateFile(`lib/
|
|
17
|
+
|
|
18
|
+
await generateFile(`lib/views/_importer.js`, { skipIfExists: true }, () => {
|
|
21
19
|
line();
|
|
22
|
-
line(`export {
|
|
20
|
+
line(`export { viewImporter as default } from 'pinstripe';`);
|
|
23
21
|
line();
|
|
24
22
|
});
|
|
25
23
|
|
|
26
|
-
await generateFile(`lib/
|
|
24
|
+
await generateFile(`lib/views/${name}`, () => {
|
|
27
25
|
line();
|
|
28
26
|
line('export default ({ renderHtml, params }) => renderHtml(`');
|
|
29
27
|
indent(() => {
|
|
@@ -33,4 +31,4 @@ defineCommand('generate-view', async ({
|
|
|
33
31
|
line();
|
|
34
32
|
});
|
|
35
33
|
});
|
|
36
|
-
}
|
|
34
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('generate-widget', async ({
|
|
2
|
+
export default async ({
|
|
5
3
|
cliUtils: { extractArg },
|
|
6
4
|
fsBuilder: { inProjectRootDir, generateFile, line, indent },
|
|
7
5
|
snakeify
|
|
@@ -14,17 +12,25 @@ defineCommand('generate-widget', async ({
|
|
|
14
12
|
|
|
15
13
|
await inProjectRootDir(async () => {
|
|
16
14
|
|
|
17
|
-
await generateFile(`lib/widgets
|
|
15
|
+
await generateFile(`lib/widgets/_importer.js`, { skipIfExists: true }, () => {
|
|
16
|
+
line();
|
|
17
|
+
line(`export { widgetImporter as default } from 'pinstripe';`);
|
|
18
18
|
line();
|
|
19
|
-
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await generateFile(`lib/widgets/${name}.client.js`, () => {
|
|
20
22
|
line();
|
|
21
|
-
line(`
|
|
23
|
+
line(`export default {`);
|
|
22
24
|
indent(() => {
|
|
23
|
-
line();
|
|
25
|
+
line(`initialize(...args){`);
|
|
26
|
+
indent(() => {
|
|
27
|
+
line(`this.constructor.parent.prototype.initialize.call(this, ...args);`);
|
|
28
|
+
});
|
|
29
|
+
line(`}`);
|
|
24
30
|
});
|
|
25
|
-
line('}
|
|
31
|
+
line('};');
|
|
26
32
|
line();
|
|
27
33
|
});
|
|
28
34
|
|
|
29
35
|
});
|
|
30
|
-
}
|
|
36
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defineCommand('init-database', async ({ runCommand }) => {
|
|
2
|
+
export default async ({ runCommand }) => {
|
|
5
3
|
await runCommand('create-database');
|
|
6
4
|
await runCommand('migrate-database');
|
|
7
5
|
await runCommand('seed-database');
|
|
8
|
-
}
|
|
6
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { Command } from '../command.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following commands are available:');
|
|
10
9
|
console.log('');
|
|
@@ -12,4 +11,4 @@ defineCommand('list-commands', () => {
|
|
|
12
11
|
console.log(` * ${chalk.green(commandName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { Migration } from '../database/migration.js'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following migrations are available:');
|
|
10
9
|
console.log('');
|
|
@@ -12,4 +11,4 @@ defineCommand('list-migrations', () => {
|
|
|
12
11
|
console.log(` * ${chalk.green(migrationName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { Row } from '../database/row.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following models are available:');
|
|
10
9
|
console.log('');
|
|
@@ -12,4 +11,4 @@ defineCommand('list-models', () => {
|
|
|
12
11
|
console.log(` * ${chalk.green(modelName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { ServiceFactory } from '../service_factory.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following services are available:');
|
|
10
9
|
console.log('');
|
|
@@ -12,5 +11,5 @@ defineCommand('list-services', () => {
|
|
|
12
11
|
console.log(` * ${chalk.green(serviceName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
16
15
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { View } from '../view.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following views are available:');
|
|
10
9
|
console.log('');
|
|
@@ -12,4 +11,4 @@ defineCommand('list-views', () => {
|
|
|
12
11
|
console.log(` * ${chalk.green(viewName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { defineCommand } from 'pinstripe';
|
|
4
3
|
|
|
5
4
|
import { NodeWrapper } from '../node_wrapper.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default () => {
|
|
8
7
|
console.log('');
|
|
9
8
|
console.log('The following widgets are available:');
|
|
10
9
|
console.log('');
|
|
11
|
-
Object.keys(NodeWrapper.classes).sort().forEach(widgetName => {
|
|
10
|
+
Object.keys(NodeWrapper.classes).filter(widgetName => !NodeWrapper.classes[widgetName].isPrivate).sort().forEach(widgetName => {
|
|
12
11
|
console.log(` * ${chalk.green(widgetName)}`);
|
|
13
12
|
});
|
|
14
13
|
console.log('');
|
|
15
|
-
}
|
|
14
|
+
};
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import * as Repl from 'repl';
|
|
3
3
|
import * as vm from 'vm';
|
|
4
4
|
import * as util from 'util';
|
|
5
|
-
import { defineCommand } from 'pinstripe';
|
|
6
5
|
|
|
7
6
|
import { ServiceFactory } from '../service_factory.js';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
export default async ({ environment, resetEnvironment }) => {
|
|
10
9
|
await new Promise(resolve => {
|
|
11
10
|
const repl = Repl.start({
|
|
12
11
|
prompt: 'pinstripe > ',
|
|
@@ -47,4 +46,4 @@ defineCommand('start-console', async ({ environment, resetEnvironment }) => {
|
|
|
47
46
|
repl.on('exit', resolve);
|
|
48
47
|
});
|
|
49
48
|
await resetEnvironment();
|
|
50
|
-
}
|
|
49
|
+
};
|