pinstripe 0.11.0 → 0.14.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/cli.js +5 -7
- package/lib/async_path_builder.js +4 -0
- package/lib/async_path_builder.test.js +11 -0
- package/lib/base.js +6 -2
- package/lib/base.test.js +18 -0
- package/lib/commands/{generate_widget.js → generate_node_wrapper.js} +5 -5
- package/lib/commands/generate_project.js +18 -0
- package/lib/commands/list_commands.js +2 -4
- package/lib/commands/list_migrations.js +2 -4
- package/lib/commands/list_models.js +2 -4
- package/lib/commands/list_node_wrappers.js +12 -0
- package/lib/commands/list_services.js +2 -4
- package/lib/commands/list_views.js +2 -4
- package/lib/css.js +101 -0
- package/lib/database/adapter.js +23 -0
- package/lib/database/adapters/mysql.js +642 -0
- package/lib/database/adapters/sqlite.js +618 -0
- package/lib/database/column.js +8 -50
- package/lib/database/constants.js +7 -50
- package/lib/database/migrator.js +6 -3
- package/lib/database/row.js +97 -90
- package/lib/database/sql.js +45 -43
- package/lib/database/sql.test.js +58 -0
- package/lib/database/table.js +50 -200
- package/lib/database/union.js +22 -54
- package/lib/database.js +30 -134
- package/lib/environment.js +4 -2
- package/lib/import_all.js +9 -0
- package/lib/index.js +1 -1
- package/lib/initialize.client.js +4 -27
- package/lib/node_wrapper.js +115 -32
- package/lib/node_wrappers/_importer.js +2 -0
- package/lib/node_wrappers/anchor.client.js +20 -0
- package/lib/{widgets/internal → node_wrappers}/document.client.js +3 -17
- package/lib/node_wrappers/form.client.js +27 -0
- package/lib/{widgets → node_wrappers}/frame.client.js +12 -31
- package/lib/{widgets/internal/actions.client.js → node_wrappers/helpers.js} +8 -11
- package/lib/node_wrappers/markdown_editor/line_inserter.client.js +14 -0
- package/lib/node_wrappers/markdown_editor.client.js +41 -0
- package/lib/{widgets/internal → node_wrappers}/overlay.client.js +15 -19
- package/lib/{widgets/internal → node_wrappers}/progress_bar.client.js +5 -9
- package/lib/services/command_names.js +6 -0
- package/lib/services/config.js +19 -7
- package/lib/services/fetch.js +11 -0
- package/lib/services/format_date.js +6 -0
- package/lib/services/migration_names.js +6 -0
- package/lib/services/model_names.js +6 -0
- package/lib/services/node_wrapper_names.js +6 -0
- package/lib/services/render_css.js +6 -0
- package/lib/services/render_form.js +51 -50
- package/lib/services/render_frame.js +11 -0
- package/lib/services/render_list.js +3 -3
- package/lib/services/render_markdown.js +39 -1
- package/lib/services/render_table.js +10 -11
- package/lib/services/send_mail.js +32 -0
- package/lib/services/service_names.js +6 -0
- package/lib/services/stylesheet_view_names.js +10 -0
- package/lib/services/theme_config.js +76 -0
- package/lib/services/view_names.js +6 -0
- package/lib/thatify.js +1 -1
- package/lib/validatable.js +1 -5
- package/lib/view.js +5 -3
- package/lib/views/_layout.js +4 -2
- package/lib/views/blocks/default.js +25 -0
- package/lib/views/blocks/help.js +139 -0
- package/lib/views/{bundle.js → bundle.js.js} +3 -4
- package/lib/views/sign_in.js +1 -6
- package/lib/views/sign_out.js +1 -1
- package/lib/views/stylesheets/components/button.css.js +56 -0
- package/lib/views/stylesheets/components/card.css.js +41 -0
- package/lib/views/stylesheets/components/form.css.js +11 -0
- package/lib/views/stylesheets/components/frame.css.js +10 -0
- package/lib/views/stylesheets/components/input.css.js +54 -0
- package/lib/views/stylesheets/components/label.css.js +14 -0
- package/lib/views/stylesheets/components/markdown_editor.css.js +53 -0
- package/lib/views/stylesheets/components/modal.css.js +77 -0
- package/lib/views/stylesheets/components/overlay.css.js +17 -0
- package/lib/views/stylesheets/components/pagination.css.js +80 -0
- package/lib/views/stylesheets/components/progress_bar.css.js +32 -0
- package/lib/views/stylesheets/components/textarea.css.js +17 -0
- package/lib/views/stylesheets/global.css +120 -0
- package/lib/views/stylesheets/reset.css +74 -0
- package/lib/views/stylesheets/vars.css +25 -0
- package/lib/virtual_node.js +30 -1
- package/package.json +9 -13
- package/pinstripe_development.db +0 -0
- package/babel.config.cjs +0 -12
- package/lib/commands/list_widgets.js +0 -14
- package/lib/views/bundle.css +0 -10384
- package/lib/views/bundle.css.map +0 -1
- package/lib/widgets/_importer.js +0 -2
- package/lib/widgets/internal/markdown_editor.client.js +0 -26
- package/lib/widgets/trigger.client.js +0 -20
- package/pinstripe.scss +0 -2
package/cli.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
|
|
5
|
-
import { importAll } from './lib/import_all.js';
|
|
6
5
|
import { project } from './lib/project.js';
|
|
7
6
|
import { Command } from './lib/command.js';
|
|
8
|
-
import {
|
|
7
|
+
import { createEnvironment } from './lib/environment.js';
|
|
9
8
|
|
|
10
9
|
(async () => {
|
|
11
10
|
const { entryPath, localPinstripePath, exists } = await project;
|
|
@@ -18,12 +17,12 @@ import { Environment } from './lib/environment.js';
|
|
|
18
17
|
stdio: 'inherit'
|
|
19
18
|
});
|
|
20
19
|
} else {
|
|
21
|
-
await importAll();
|
|
22
20
|
if(entryPath){
|
|
23
|
-
|
|
24
|
-
await importAll();
|
|
21
|
+
import(entryPath);
|
|
25
22
|
}
|
|
26
23
|
|
|
24
|
+
const { runCommand, resetEnvironment } = await createEnvironment();
|
|
25
|
+
|
|
27
26
|
if(exists){
|
|
28
27
|
Command.unregister('generate-project');
|
|
29
28
|
} else {
|
|
@@ -34,8 +33,7 @@ import { Environment } from './lib/environment.js';
|
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
const { runCommand, resetEnvironment } = Environment.new();
|
|
36
|
+
|
|
39
37
|
try {
|
|
40
38
|
await runCommand(...args);
|
|
41
39
|
} catch(e) {
|
|
@@ -15,6 +15,10 @@ export const AsyncPathBuilder = Base.extend().include({
|
|
|
15
15
|
return new this.constructor(this._startObject, [...this._path, args ]);
|
|
16
16
|
},
|
|
17
17
|
|
|
18
|
+
get toString(){
|
|
19
|
+
return this.__getMissing('toString');
|
|
20
|
+
},
|
|
21
|
+
|
|
18
22
|
then(...args){
|
|
19
23
|
return unwrap(this._startObject, [...this._path]).then(...args);
|
|
20
24
|
}
|
|
@@ -25,3 +25,14 @@ test('AsyncPathBuilder (2)', async () => {
|
|
|
25
25
|
expect(await foo.bar().baz()).toBe("boo");
|
|
26
26
|
expect(await foo.bar().baz().length).toBe(3);
|
|
27
27
|
});
|
|
28
|
+
|
|
29
|
+
test('AsyncPathBuilder (3)', async () => {
|
|
30
|
+
const foo = AsyncPathBuilder.new({
|
|
31
|
+
toString(){
|
|
32
|
+
return "hello world";
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(await foo.toString()).toBe("hello world");
|
|
37
|
+
});
|
|
38
|
+
|
package/lib/base.js
CHANGED
|
@@ -117,17 +117,21 @@ const assignProps = (target, ...sources) => {
|
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
const descriptor = { ...Object.getOwnPropertyDescriptor(source, name) };
|
|
120
|
-
const { get } = descriptor;
|
|
120
|
+
const { get, set } = descriptor;
|
|
121
|
+
const { get: targetGet, set: targetSet } = (Object.getOwnPropertyDescriptor(target, name) || {});
|
|
121
122
|
if(get){
|
|
122
123
|
descriptor.get = function(...args){
|
|
123
124
|
return get.call(this.__proxy || this, ...args);
|
|
124
125
|
};
|
|
126
|
+
} else if(targetGet) {
|
|
127
|
+
descriptor.get = targetGet;
|
|
125
128
|
}
|
|
126
|
-
const { set } = descriptor;
|
|
127
129
|
if(set){
|
|
128
130
|
descriptor.set = function(...args){
|
|
129
131
|
set.call(this.__proxy || this, ...args);
|
|
130
132
|
};
|
|
133
|
+
} else if(targetSet){
|
|
134
|
+
descriptor.set = targetSet;
|
|
131
135
|
}
|
|
132
136
|
Object.defineProperty(target, name, descriptor);
|
|
133
137
|
});
|
package/lib/base.test.js
CHANGED
|
@@ -78,3 +78,21 @@ test(`Base - can produce dynamic keys`, () => {
|
|
|
78
78
|
|
|
79
79
|
expect(Object.keys(fixture)).toEqual(['foo', 'bar']);
|
|
80
80
|
});
|
|
81
|
+
|
|
82
|
+
test(`Base - getters and setters with same name can be defined independently`, () => {
|
|
83
|
+
const fixture = Base.extend().include({
|
|
84
|
+
meta(){
|
|
85
|
+
this.prototype.assignProps({
|
|
86
|
+
get foo(){
|
|
87
|
+
return 'bar';
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
set foo(value){
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
}).new();
|
|
96
|
+
|
|
97
|
+
expect(fixture.foo).toEqual('bar');
|
|
98
|
+
})
|
|
@@ -6,23 +6,23 @@ export default async ({
|
|
|
6
6
|
}) => {
|
|
7
7
|
const name = snakeify(extractArg(''));
|
|
8
8
|
if(name == ''){
|
|
9
|
-
console.error('A
|
|
9
|
+
console.error('A node wrapper name must be given.');
|
|
10
10
|
process.exit();
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
await inProjectRootDir(async () => {
|
|
14
14
|
|
|
15
|
-
await generateFile(`lib/
|
|
15
|
+
await generateFile(`lib/node_wrappers/_importer.js`, { skipIfExists: true }, () => {
|
|
16
16
|
line();
|
|
17
|
-
line(`export {
|
|
17
|
+
line(`export { nodeWrapperImporter as default } from 'pinstripe';`);
|
|
18
18
|
line();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
await generateFile(`lib/
|
|
21
|
+
await generateFile(`lib/node_wrappers/${name}.client.js`, () => {
|
|
22
22
|
line();
|
|
23
23
|
line(`export default {`);
|
|
24
24
|
indent(() => {
|
|
25
|
-
line(`initialize(
|
|
25
|
+
line(`initialize(){`);
|
|
26
26
|
indent(() => {
|
|
27
27
|
line(`this.constructor.parent.prototype.initialize.call(this, ...args);`);
|
|
28
28
|
});
|
|
@@ -36,11 +36,29 @@ export default async ({
|
|
|
36
36
|
await generateFile(`lib/index.js`, () => {
|
|
37
37
|
line();
|
|
38
38
|
line(`import { importAll } from 'pinstripe';`);
|
|
39
|
+
dependencies.forEach((dependency) => {
|
|
40
|
+
if(dependency != 'pinstripe') line(`import '${dependency}';`);
|
|
41
|
+
});
|
|
39
42
|
line();
|
|
40
43
|
line(`importAll(import.meta.url);`);
|
|
41
44
|
line();
|
|
42
45
|
});
|
|
43
46
|
|
|
47
|
+
await generateFile(`README.md`, () => {
|
|
48
|
+
line();
|
|
49
|
+
line(`# ${name}`);
|
|
50
|
+
line();
|
|
51
|
+
line('## Getting started');
|
|
52
|
+
line();
|
|
53
|
+
line('```bash');
|
|
54
|
+
indent(() => {
|
|
55
|
+
line('pinstripe init-database');
|
|
56
|
+
line('pinstripe start-server');
|
|
57
|
+
});
|
|
58
|
+
line('```');
|
|
59
|
+
line();
|
|
60
|
+
});
|
|
61
|
+
|
|
44
62
|
spawnSync('yarn', [ 'add', ...dependencies ], {
|
|
45
63
|
stdio: 'inherit'
|
|
46
64
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
4
|
+
export default ({ commandNames }) => {
|
|
7
5
|
console.log('');
|
|
8
6
|
console.log('The following commands are available:');
|
|
9
7
|
console.log('');
|
|
10
|
-
|
|
8
|
+
commandNames.forEach(commandName => {
|
|
11
9
|
console.log(` * ${chalk.green(commandName)}`);
|
|
12
10
|
});
|
|
13
11
|
console.log('');
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
4
|
+
export default ({ migrationNames }) => {
|
|
7
5
|
console.log('');
|
|
8
6
|
console.log('The following migrations are available:');
|
|
9
7
|
console.log('');
|
|
10
|
-
|
|
8
|
+
migrationNames.forEach(migrationName => {
|
|
11
9
|
console.log(` * ${chalk.green(migrationName)}`);
|
|
12
10
|
});
|
|
13
11
|
console.log('');
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
4
|
+
export default ({ modelNames }) => {
|
|
7
5
|
console.log('');
|
|
8
6
|
console.log('The following models are available:');
|
|
9
7
|
console.log('');
|
|
10
|
-
|
|
8
|
+
modelNames.forEach(modelName => {
|
|
11
9
|
console.log(` * ${chalk.green(modelName)}`);
|
|
12
10
|
});
|
|
13
11
|
console.log('');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
export default ({ nodeWrapperNames }) => {
|
|
5
|
+
console.log('');
|
|
6
|
+
console.log('The following node wrappers are available:');
|
|
7
|
+
console.log('');
|
|
8
|
+
nodeWrapperNames.forEach(nodeWrapperName => {
|
|
9
|
+
console.log(` * ${chalk.green(nodeWrapperName)}`);
|
|
10
|
+
});
|
|
11
|
+
console.log('');
|
|
12
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
4
|
+
export default ({ serviceNames }) => {
|
|
7
5
|
console.log('');
|
|
8
6
|
console.log('The following services are available:');
|
|
9
7
|
console.log('');
|
|
10
|
-
|
|
8
|
+
serviceNames.forEach(serviceName => {
|
|
11
9
|
console.log(` * ${chalk.green(serviceName)}`);
|
|
12
10
|
});
|
|
13
11
|
console.log('');
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
4
|
+
export default ({ viewNames }) => {
|
|
7
5
|
console.log('');
|
|
8
6
|
console.log('The following views are available:');
|
|
9
7
|
console.log('');
|
|
10
|
-
|
|
8
|
+
viewNames.forEach(viewName => {
|
|
11
9
|
console.log(` * ${chalk.green(viewName)}`);
|
|
12
10
|
});
|
|
13
11
|
console.log('');
|
package/lib/css.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
|
|
2
|
+
import { Base } from './base.js';
|
|
3
|
+
|
|
4
|
+
export const Css = Base.extend().include({
|
|
5
|
+
|
|
6
|
+
meta(){
|
|
7
|
+
this.assignProps({
|
|
8
|
+
render(...rules){
|
|
9
|
+
return this.new(compileRules(deepMerge({}, ...rules)));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
initialize(value){
|
|
15
|
+
this.value = value;
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
toString(){
|
|
19
|
+
return this.value;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
toResponseArray(status = 200, headers = {}){
|
|
23
|
+
return [status, {'content-type': 'text/css', ...headers}, [this.value.trim()]];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const compileRules = (rules, path = [], out = []) => {
|
|
28
|
+
const props = {};
|
|
29
|
+
|
|
30
|
+
Object.keys(rules).forEach(name => {
|
|
31
|
+
const value = rules[name];
|
|
32
|
+
if(typeof value == 'object') return;
|
|
33
|
+
props[name] = value;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if(path.length && Object.keys(props).length){
|
|
37
|
+
out.push(compileRule(path, props));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Object.keys(rules).forEach(name => {
|
|
41
|
+
const value = rules[name];
|
|
42
|
+
if(typeof value != 'object') return;
|
|
43
|
+
compileRules(value, [ ...path, name ], out);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if(!path.length) return out.join('\n');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const compileRule = (path, props) => {
|
|
50
|
+
const atRules = [];
|
|
51
|
+
let selector = '';
|
|
52
|
+
path.forEach((segment, i) => {
|
|
53
|
+
if(segment.match(/^@/)){
|
|
54
|
+
atRules.push(segment);
|
|
55
|
+
} else {
|
|
56
|
+
segment = segment.match(/&/) ? segment : `${i ? '& ' : '&'}${segment}`.replace(/,\s*/g, ', & ');
|
|
57
|
+
selector = selector.split(/,\s*/).map(selector => segment.replace(/&/g, selector)).join(', ');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const out = [];
|
|
62
|
+
const indent = [];
|
|
63
|
+
|
|
64
|
+
atRules.forEach(rule => {
|
|
65
|
+
out.push(`${indent.join('')}${rule} {`);
|
|
66
|
+
indent.push(' ');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
out.push(`${indent.join('')}${selector} {`);
|
|
70
|
+
indent.push(' ');
|
|
71
|
+
Object.keys(props).forEach(name => {
|
|
72
|
+
const value = props[name];
|
|
73
|
+
out.push(`${indent.join('')}${normaliseName(name)}: ${name == 'content' ? `'${value}'` : value};`);
|
|
74
|
+
})
|
|
75
|
+
indent.pop();
|
|
76
|
+
out.push(`${indent.join('')}}`);
|
|
77
|
+
|
|
78
|
+
atRules.forEach(() => {
|
|
79
|
+
indent.pop();
|
|
80
|
+
out.push(`${indent.join('')}}`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return out.join('\n');
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const normaliseName = name => name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
87
|
+
|
|
88
|
+
const deepMerge = (destination = {}, ...sources) => {
|
|
89
|
+
sources.forEach(source => {
|
|
90
|
+
Object.keys(source).forEach(key => {
|
|
91
|
+
const value = source[key];
|
|
92
|
+
if(typeof value == 'object') {
|
|
93
|
+
destination[key] = deepMerge(typeof destination[key] == 'object' ? destination[key] : {}, value);
|
|
94
|
+
} else {
|
|
95
|
+
destination[key] = source[key];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
return destination;
|
|
100
|
+
};
|
|
101
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { Base } from "../base.js";
|
|
3
|
+
import { Registrable } from '../registrable.js';
|
|
4
|
+
|
|
5
|
+
export const Adapter = Base.extend().include({
|
|
6
|
+
meta(){
|
|
7
|
+
this.include(Registrable);
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
initialize(config){
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const createAdapterDeligator = namespace => name => {
|
|
16
|
+
return function(...args){
|
|
17
|
+
const { methods } = this._adapter;
|
|
18
|
+
if(methods && methods[namespace] && methods[namespace][name]){
|
|
19
|
+
return this._adapter.methods[namespace][name].call(this, ...args);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Adapter method '${namespace}.${name}' does not exist.`)
|
|
22
|
+
}
|
|
23
|
+
};
|