pinstripe 0.9.0 → 0.12.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/README.md +1 -1
- 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 +13 -2
- package/lib/base.test.js +30 -28
- 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 +11 -9
- package/lib/commands/generate_node_wrapper.js +36 -0
- 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/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_node_wrappers.js +14 -0
- package/lib/commands/list_services.js +2 -3
- package/lib/commands/list_views.js +2 -3
- 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 +17 -10
- package/lib/constants.js +0 -9
- package/lib/css.js +101 -0
- package/lib/database/adapter.js +23 -0
- package/lib/database/adapters/mysql.js +629 -0
- package/lib/database/adapters/sqlite.js +590 -0
- package/lib/database/column.js +8 -48
- package/lib/database/constants.js +25 -44
- package/lib/database/migration.js +20 -0
- package/lib/database/migrator.js +6 -3
- package/lib/database/row.js +152 -96
- package/lib/database/sql.js +47 -44
- package/lib/database/sql.test.js +58 -0
- package/lib/database/table.js +77 -202
- package/lib/database/union.js +21 -39
- package/lib/database.js +30 -121
- package/lib/environment.js +4 -2
- package/lib/html.js +1 -1
- package/lib/import_all.js +22 -9
- package/lib/index.js +7 -8
- package/lib/initialize.client.js +3 -3
- 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 +242 -26
- package/lib/node_wrappers/_importer.js +2 -0
- package/lib/node_wrappers/anchor.client.js +18 -0
- package/lib/{widgets → node_wrappers}/document.client.js +12 -19
- package/lib/node_wrappers/form.client.js +16 -0
- package/lib/{widgets → node_wrappers}/frame.client.js +32 -11
- package/lib/node_wrappers/helpers.js +48 -0
- package/lib/node_wrappers/markdown_editor/line_inserter.client.js +14 -0
- package/lib/node_wrappers/markdown_editor.client.js +34 -0
- package/lib/node_wrappers/overlay.client.js +26 -0
- package/lib/{widgets/document → node_wrappers}/progress_bar.client.js +7 -6
- 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 +19 -8
- package/lib/services/cookies.js +2 -4
- package/lib/services/database.js +2 -5
- package/lib/services/fetch.js +33 -23
- 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_css.js +6 -0
- package/lib/services/render_file.js +4 -7
- package/lib/services/render_form.js +108 -66
- package/lib/services/render_html.js +2 -4
- package/lib/services/render_list.js +58 -0
- package/lib/services/render_markdown.js +44 -0
- package/lib/services/render_table.js +67 -0
- package/lib/services/render_view.js +7 -18
- 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/theme_config.js +76 -0
- package/lib/services/view.js +4 -0
- package/lib/thatify.js +1 -1
- package/lib/url.js +12 -4
- package/lib/url.test.js +5 -1
- package/lib/validatable.js +1 -5
- package/lib/view.js +109 -2
- package/lib/views/_importer.js +2 -0
- package/lib/views/{layout.js → _layout.js} +13 -17
- package/lib/views/base.css.js +657 -0
- package/lib/views/blocks/default.js +25 -0
- package/lib/views/blocks/help.js +139 -0
- package/lib/views/bundle.js.js +36 -0
- package/lib/{controllers → views}/sign_in.js +5 -4
- package/lib/views/sign_out.js +15 -0
- package/lib/virtual_node.js +41 -46
- package/package.json +10 -14
- package/babel.config.cjs +0 -12
- package/lib/commands/generate_controller.js +0 -33
- package/lib/commands/generate_widget.js +0 -30
- package/lib/commands/list_controllers.js +0 -15
- package/lib/commands/list_widgets.js +0 -15
- package/lib/controller.js +0 -19
- package/lib/controllers/bundle.js +0 -62
- package/lib/controllers/sign_out.js +0 -15
- package/lib/renderable.js +0 -25
- package/lib/scss/index.scss +0 -2
- package/lib/services/render_controller.js +0 -11
- package/lib/services/render_script.js +0 -14
- package/lib/static/bundle.css +0 -10308
- 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 -61
- package/lib/widgets/input.client.js +0 -23
- package/lib/widgets/overlay.client.js +0 -27
- package/lib/widgets/script.client.js +0 -9
- package/pinstripe.scss +0 -2
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
import { NodeWrapper } from '../node_wrapper.js';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
console.log('');
|
|
8
|
+
console.log('The following node wrappers are available:');
|
|
9
|
+
console.log('');
|
|
10
|
+
Object.keys(NodeWrapper.classes).sort().forEach(nodeWrapperName => {
|
|
11
|
+
console.log(` * ${chalk.green(nodeWrapperName)}`);
|
|
12
|
+
});
|
|
13
|
+
console.log('');
|
|
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
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -4,9 +4,7 @@ import Busboy from 'busboy';
|
|
|
4
4
|
import { default as qs} from 'qs';
|
|
5
5
|
const { parse: parseQueryString } = qs;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
defineCommand('start-server', async ({ fetch }) => {
|
|
7
|
+
export default async ({ fetch }) => {
|
|
10
8
|
const host = process.env.HOST || '127.0.0.1';
|
|
11
9
|
const port = process.env.PORT || 3000;
|
|
12
10
|
|
|
@@ -22,14 +20,14 @@ defineCommand('start-server', async ({ fetch }) => {
|
|
|
22
20
|
response.end();
|
|
23
21
|
} catch (e){
|
|
24
22
|
response.statusCode = 500;
|
|
25
|
-
response.setHeader('
|
|
23
|
+
response.setHeader('content-type', 'text/plain');
|
|
26
24
|
response.end((e.stack || e).toString());
|
|
27
25
|
}
|
|
28
26
|
console.log(`${request.method}: ${request.url} (${response.statusCode})`);
|
|
29
27
|
}).listen(port, host, () => {
|
|
30
28
|
console.log(`Pinstripe running at http://${host}:${port}/`)
|
|
31
29
|
});
|
|
32
|
-
}
|
|
30
|
+
};
|
|
33
31
|
|
|
34
32
|
const extractParams = async (request) => {
|
|
35
33
|
const { method, url, headers } = request;
|
|
@@ -51,18 +49,27 @@ const parseBody = (request) => new Promise((resolve) => {
|
|
|
51
49
|
const out = {};
|
|
52
50
|
const busboy = new Busboy({ headers: request.headers });
|
|
53
51
|
|
|
54
|
-
busboy.on('file', function(fieldname, file, filename, encoding,
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
busboy.on('file', function(fieldname, file, filename, encoding, mimeType) {
|
|
53
|
+
const chunks = [];
|
|
54
|
+
|
|
55
|
+
file.on('data', chunk => {
|
|
56
|
+
chunks.push(Buffer.from(chunk));
|
|
58
57
|
});
|
|
58
|
+
|
|
59
59
|
file.on('end', () => {
|
|
60
|
-
out[fieldname] =
|
|
60
|
+
out[fieldname] = {
|
|
61
|
+
filename,
|
|
62
|
+
encoding,
|
|
63
|
+
mimeType,
|
|
64
|
+
data: Buffer.concat(chunks)
|
|
65
|
+
};
|
|
61
66
|
});
|
|
62
67
|
});
|
|
68
|
+
|
|
63
69
|
busboy.on('field', (fieldname, value) => {
|
|
64
70
|
out[fieldname] = value
|
|
65
71
|
});
|
|
72
|
+
|
|
66
73
|
busboy.on('finish', () => resolve(out));
|
|
67
74
|
|
|
68
75
|
request.pipe(busboy);
|
package/lib/constants.js
CHANGED
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
|
+
};
|