pinstripe 0.20.0 → 0.22.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/component.js +1 -22
- package/lib/components/{pinstripe_anchor.js → anchor.js} +5 -3
- package/lib/components/{pinstripe_body.js → body.js} +4 -2
- package/lib/components/{pinstripe_document.js → document.js} +4 -2
- package/lib/components/{pinstripe_form.js → form.js} +4 -2
- package/lib/components/{pinstripe_frame.js → frame.js} +4 -2
- package/lib/components/index.js +9 -0
- package/lib/components/{pinstripe_markdown_editor.js → markdown_editor.js} +2 -2
- package/lib/components/{pinstripe_overlay.js → overlay.js} +4 -2
- package/lib/components/{pinstripe_progress_bar.js → progress_bar.js} +4 -2
- package/lib/index.js +1 -11
- package/package.json +7 -31
- package/cli.js +0 -46
- package/lib/class.js +0 -64
- package/lib/client.js +0 -21
- package/lib/command.js +0 -39
- package/lib/commands/_file_importer.js +0 -1
- package/lib/commands/drop_database.js +0 -6
- package/lib/commands/generate_command.js +0 -39
- package/lib/commands/generate_component.js +0 -37
- package/lib/commands/generate_migration.js +0 -47
- package/lib/commands/generate_model.js +0 -43
- package/lib/commands/generate_project.js +0 -131
- package/lib/commands/generate_service.js +0 -32
- package/lib/commands/generate_static_site.js +0 -74
- package/lib/commands/generate_view.js +0 -44
- package/lib/commands/init_database.js +0 -9
- package/lib/commands/list_commands.js +0 -15
- package/lib/commands/list_components.js +0 -16
- package/lib/commands/list_migrations.js +0 -15
- package/lib/commands/list_models.js +0 -15
- package/lib/commands/list_services.js +0 -15
- package/lib/commands/list_views.js +0 -16
- package/lib/commands/migrate_database.js +0 -6
- package/lib/commands/purge_old_sessions.js +0 -12
- package/lib/commands/reset_database.js +0 -9
- package/lib/commands/seed_database.js +0 -6
- package/lib/commands/show_config.js +0 -6
- package/lib/commands/start_repl.js +0 -6
- package/lib/commands/start_server.js +0 -9
- package/lib/components/_file_importer.js +0 -1
- package/lib/constants.js +0 -22
- package/lib/context.js +0 -40
- package/lib/database/client.js +0 -199
- package/lib/database/column_reference.js +0 -13
- package/lib/database/constants.js +0 -87
- package/lib/database/index.js +0 -7
- package/lib/database/migration.js +0 -30
- package/lib/database/migrator.js +0 -28
- package/lib/database/row.js +0 -383
- package/lib/database/singleton.js +0 -12
- package/lib/database/table.js +0 -514
- package/lib/database/table_reference.js +0 -33
- package/lib/database/union.js +0 -128
- package/lib/database.js +0 -135
- package/lib/defer.js +0 -35
- package/lib/defer.test.js +0 -37
- package/lib/extensions/_file_importer.js +0 -2
- package/lib/extensions/multi-app/index.js +0 -4
- package/lib/extensions/multi-app/views/_file_importer.js +0 -2
- package/lib/extensions/multi-app/views/apps/default.js +0 -6
- package/lib/extensions/multi-app/views/apps/guard.js +0 -7
- package/lib/extensions/multi-app/views/guard.js +0 -21
- package/lib/extensions/multi-tenant/database/row.js +0 -27
- package/lib/extensions/multi-tenant/database/table.js +0 -30
- package/lib/extensions/multi-tenant/database.js +0 -8
- package/lib/extensions/multi-tenant/index.js +0 -4
- package/lib/extensions/multi-tenant/migrations/1627976174_create_tenant_table_and_add_tenant_id_to_existing_tables.js +0 -20
- package/lib/extensions/multi-tenant/migrations/_file_importer.js +0 -2
- package/lib/extensions/multi-tenant/services/_file_importer.js +0 -2
- package/lib/extensions/multi-tenant/services/database.js +0 -32
- package/lib/html.js +0 -73
- package/lib/import_all.js +0 -81
- package/lib/inflector.js +0 -173
- package/lib/migrations/1627976184_create_user.js +0 -13
- package/lib/migrations/1628057822_create_session.js +0 -10
- package/lib/migrations/_file_importer.js +0 -1
- package/lib/model.js +0 -110
- package/lib/models/_file_importer.js +0 -1
- package/lib/models/session.js +0 -9
- package/lib/models/user.js +0 -53
- package/lib/project.js +0 -71
- package/lib/registry.js +0 -133
- package/lib/service_consumer.js +0 -16
- package/lib/service_factory.js +0 -20
- package/lib/services/_file_importer.js +0 -1
- package/lib/services/args.js +0 -9
- package/lib/services/bot.js +0 -69
- package/lib/services/cli_utils.js +0 -77
- package/lib/services/client_builder.js +0 -68
- package/lib/services/config.js +0 -63
- package/lib/services/cookies.js +0 -19
- package/lib/services/create_model.js +0 -8
- package/lib/services/database.js +0 -14
- package/lib/services/defer.js +0 -8
- package/lib/services/fetch.js +0 -116
- package/lib/services/format_date.js +0 -8
- package/lib/services/fs_builder.js +0 -132
- package/lib/services/inflector.js +0 -8
- package/lib/services/initial_params.js +0 -13
- package/lib/services/params.js +0 -13
- package/lib/services/parse_html.js +0 -8
- package/lib/services/project.js +0 -8
- package/lib/services/render_form.js +0 -161
- package/lib/services/render_html.js +0 -8
- package/lib/services/render_markdown.js +0 -44
- package/lib/services/render_view.js +0 -8
- package/lib/services/repl.js +0 -54
- package/lib/services/run_command.js +0 -8
- package/lib/services/send_mail.js +0 -46
- package/lib/services/server.js +0 -90
- package/lib/services/session.js +0 -19
- package/lib/services/view_names.js +0 -8
- package/lib/singleton.js +0 -13
- package/lib/string_reader.js +0 -22
- package/lib/trapify.js +0 -32
- package/lib/unescape_html.js +0 -21
- package/lib/unescape_html.test.js +0 -9
- package/lib/validation_error.js +0 -7
- package/lib/view.js +0 -45
- package/lib/view_file_importers/ejs.js +0 -82
- package/lib/view_file_importers/md.js +0 -42
- package/lib/views/_file_importer.js +0 -1
- package/lib/views/assets/javascripts/all.js.js +0 -7
- package/lib/views/assets/javascripts/all.js.map.js +0 -7
- package/lib/views/assets/stylesheets/all.css.js +0 -28
- package/lib/views/assets/stylesheets/components/button.css +0 -43
- package/lib/views/assets/stylesheets/components/card.css +0 -29
- package/lib/views/assets/stylesheets/components/form.css +0 -4
- package/lib/views/assets/stylesheets/components/frame.css +0 -3
- package/lib/views/assets/stylesheets/components/input.css +0 -40
- package/lib/views/assets/stylesheets/components/label.css +0 -9
- package/lib/views/assets/stylesheets/components/modal.css +0 -62
- package/lib/views/assets/stylesheets/components/overlay.css +0 -11
- package/lib/views/assets/stylesheets/components/pagination.css +0 -60
- package/lib/views/assets/stylesheets/components/progress_bar.css +0 -20
- package/lib/views/assets/stylesheets/components/textarea.css +0 -10
- package/lib/views/assets/stylesheets/global.css +0 -120
- package/lib/views/assets/stylesheets/reset.css +0 -74
- package/lib/views/assets/stylesheets/vars.css +0 -25
- package/lib/views/sign_in/index.js +0 -32
- package/lib/views/sign_in/verify_password.js +0 -52
- package/lib/views/sign_out.js +0 -16
- package/lib/virtual_node.js +0 -172
- package/lib/virtual_node.test.js +0 -25
- package/lib/workspace.js +0 -21
package/lib/component.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { Class, TEXT_ONLY_TAGS, Inflector, VirtualNode, Registry } from "haberdash";
|
|
3
3
|
|
|
4
|
-
import { VirtualNode } from './virtual_node.js';
|
|
5
4
|
import { EventWrapper } from './event_wrapper.js';
|
|
6
|
-
import { TEXT_ONLY_TAGS } from './constants.js';
|
|
7
|
-
|
|
8
|
-
import { Class } from './class.js';
|
|
9
|
-
import { Registry } from './registry.js';
|
|
10
|
-
import { Client } from './client.js'; // pinstripe-if-client: const Client = undefined;
|
|
11
|
-
import { Inflector } from './inflector.js';
|
|
12
5
|
|
|
13
6
|
export const Component = Class.extend().include({
|
|
14
7
|
meta(){
|
|
15
8
|
this.include(Registry);
|
|
16
9
|
|
|
17
|
-
const { importFile } = this;
|
|
18
|
-
|
|
19
10
|
this.assignProps({
|
|
20
11
|
instanceFor(node){
|
|
21
12
|
if(!node._component){
|
|
@@ -31,18 +22,6 @@ export const Component = Class.extend().include({
|
|
|
31
22
|
|
|
32
23
|
normalizeName(name){
|
|
33
24
|
return Inflector.instance.dasherize(name);
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
async importFile(params){
|
|
37
|
-
const { filePath, relativeFilePathWithoutExtension } = params;
|
|
38
|
-
if((await import(filePath)).default){
|
|
39
|
-
Client.instance.addModule(`
|
|
40
|
-
import { Component } from ${JSON.stringify(fileURLToPath(`${import.meta.url}/../index.js`))};
|
|
41
|
-
import include from ${JSON.stringify(filePath)};
|
|
42
|
-
Component.register(${JSON.stringify(relativeFilePathWithoutExtension)}, include);
|
|
43
|
-
`);
|
|
44
|
-
}
|
|
45
|
-
return importFile.call(this, params);
|
|
46
25
|
}
|
|
47
26
|
});
|
|
48
27
|
},
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
import { Component } from "../component.js";
|
|
2
3
|
import { loadFrame, removeFrame } from "./helpers.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
Component.register('pinstripe-anchor', {
|
|
5
6
|
initialize(...args){
|
|
6
7
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
8
|
|
|
8
9
|
const { ignoreEventsFromChildren = false } = this.data;
|
|
9
10
|
this.on('click', (event) => {
|
|
10
11
|
if(ignoreEventsFromChildren && event.target != this) return;
|
|
12
|
+
const { action = 'load', confirm, target = '_self', method = 'GET', href } = { ...this.attributes, ...this.data };
|
|
13
|
+
if(new URL(href, window.location.href).host != window.location.host) return;
|
|
11
14
|
event.preventDefault();
|
|
12
15
|
event.stopPropagation();
|
|
13
|
-
const { action = 'load', confirm, target = '_self', method = 'GET', href } = { ...this.attributes, ...this.data };
|
|
14
16
|
if(action == 'load') loadFrame.call(this, confirm, target, method, href);
|
|
15
17
|
if(action == 'remove') removeFrame.call(this, confirm, target);
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
if(this.is('input, textarea')) this.on('keyup', (event) => this.trigger('click'));
|
|
19
21
|
}
|
|
20
|
-
};
|
|
22
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import { Component } from "../component.js";
|
|
3
|
+
|
|
4
|
+
Component.register('pinstripe-body', {
|
|
3
5
|
initialize(...args){
|
|
4
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
5
7
|
|
|
@@ -30,4 +32,4 @@ export default {
|
|
|
30
32
|
unclip(){
|
|
31
33
|
this.shadow.find('.styles').patch('');
|
|
32
34
|
}
|
|
33
|
-
};
|
|
35
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
|
+
import { Component } from "../component.js";
|
|
3
|
+
|
|
2
4
|
import { loadFrame } from "./helpers.js";
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
Component.register('pinstripe-form', {
|
|
5
7
|
initialize(...args){
|
|
6
8
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
9
|
|
|
@@ -22,4 +24,4 @@ export default {
|
|
|
22
24
|
get hasUnsavedChanges(){
|
|
23
25
|
return this.data.hasUnsavedChanges || JSON.stringify(this.values) != this._initialHash;
|
|
24
26
|
}
|
|
25
|
-
};
|
|
27
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import { Component } from "../component.js";
|
|
3
|
+
|
|
4
|
+
Component.register('pinstripe-frame', {
|
|
3
5
|
initialize(...args){
|
|
4
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
5
7
|
|
|
@@ -44,4 +46,4 @@ export default {
|
|
|
44
46
|
|
|
45
47
|
return this.patch(await response.text());
|
|
46
48
|
}
|
|
47
|
-
};
|
|
49
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Component } from '../component.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Component.register('pinstripe-markdown-editor', {
|
|
5
5
|
initialize(...args){
|
|
6
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
7
|
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
editorTextarea.node.selectionStart = position;
|
|
42
42
|
editorTextarea.node.selectionEnd = position;
|
|
43
43
|
}
|
|
44
|
-
};
|
|
44
|
+
});
|
|
45
45
|
|
|
46
46
|
Component.register('pinstripe-markdown-editor/line-inserter', {
|
|
47
47
|
initialize(...args){
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import { Component } from "../component.js";
|
|
3
|
+
|
|
4
|
+
Component.register('pinstripe-progress-bar', {
|
|
3
5
|
initialize(...args){
|
|
4
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
5
7
|
|
|
@@ -73,4 +75,4 @@ export default {
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
};
|
|
78
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
import './components/index.js';
|
|
2
3
|
import './initialize.js';
|
|
3
4
|
|
|
4
|
-
export * from './class.js';
|
|
5
|
-
export * from './command.js'; // pinstripe-if-client: export const Command = undefined;
|
|
6
|
-
export * from './context.js'; // pinstripe-if-client: export const Context = undefined;
|
|
7
5
|
export * from './component.js';
|
|
8
|
-
export * from './database.js'; // pinstripe-if-client: export const Database = undefined;
|
|
9
|
-
export * from './html.js'; // pinstripe-if-client: export const Html = undefined;
|
|
10
|
-
export * from './import_all.js'; // pinstripe-if-client: export const importAll = undefined;
|
|
11
|
-
export * from './inflector.js'; // pinstripe-if-client: export const Inflector = undefined;
|
|
12
|
-
export * from './project.js'; // pinstripe-if-client: export const project = undefined;
|
|
13
|
-
export * from './service_factory.js'; // pinstripe-if-client: export const ServiceFactory = undefined;
|
|
14
|
-
export * from './view.js'; // pinstripe-if-client: export const View = undefined;
|
|
15
|
-
export * from './workspace.js'; // pinstripe-if-client: export const Workspace = undefined;
|
package/package.json
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "pinstripe",
|
|
4
|
-
"description": "A slick web framework for
|
|
5
|
-
"version": "0.
|
|
4
|
+
"description": "A slick web framework for your browser.",
|
|
5
|
+
"version": "0.22.0",
|
|
6
6
|
"author": "Jody Salt",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": "./lib/index.js"
|
|
10
|
-
"./database": "./lib/database/index.js",
|
|
11
|
-
"./esbuild-plugin": "./lib/esbuild_plugin.js",
|
|
12
|
-
"./multi-tenant": "./lib/extensions/multi-tenant/index.js",
|
|
13
|
-
"./multi-app": "./lib/extensions/multi-app/index.js"
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"pinstripe": "./cli.js"
|
|
9
|
+
".": "./lib/index.js"
|
|
17
10
|
},
|
|
18
11
|
"scripts": {
|
|
19
12
|
"clean": "rm -rf ./node_modules",
|
|
20
|
-
"start": "IS_LOCAL_PINSTRIPE=true pinstripe start-server",
|
|
21
13
|
"test": "yarn test:unit",
|
|
22
|
-
"test:unit": "jest lib"
|
|
14
|
+
"test:unit": "#jest lib"
|
|
23
15
|
},
|
|
24
16
|
"devDependencies": {
|
|
25
17
|
"@babel/core": "^7.9.0",
|
|
@@ -27,26 +19,10 @@
|
|
|
27
19
|
"@babel/preset-env": "^7.9.0",
|
|
28
20
|
"babel-jest": "^25.1.0",
|
|
29
21
|
"jest": "^28.0.1",
|
|
30
|
-
"jest-environment-jsdom": "^29.1.2"
|
|
31
|
-
"ramda": "^0.27.0"
|
|
22
|
+
"jest-environment-jsdom": "^29.1.2"
|
|
32
23
|
},
|
|
33
24
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"busboy": "^0.3.1",
|
|
36
|
-
"chalk": "^4.1.0",
|
|
37
|
-
"cron-parser": "^4.3.0",
|
|
38
|
-
"esbuild": "^0.15.12",
|
|
39
|
-
"html-entities": "^2.3.2",
|
|
40
|
-
"js-yaml": "^4.1.0",
|
|
41
|
-
"luxon": "^2.3.1",
|
|
42
|
-
"markdown-it": "^12.2.0",
|
|
43
|
-
"memfs": "^3.2.2",
|
|
44
|
-
"mime-types": "^2.1.28",
|
|
45
|
-
"mysql2": "^2.3.3",
|
|
46
|
-
"nodemailer": "^6.7.2",
|
|
47
|
-
"sqlite3": "^5.0.2",
|
|
48
|
-
"tmp": "^0.2.1",
|
|
49
|
-
"unionfs": "^4.4.0"
|
|
25
|
+
"haberdash": "^0.22.0"
|
|
50
26
|
},
|
|
51
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4e3ec10ab9860717febe279c83da6ff4fbbc88d8"
|
|
52
28
|
}
|
package/cli.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawn } from 'child_process';
|
|
4
|
-
|
|
5
|
-
import { Project } from './lib/project.js';
|
|
6
|
-
import { Command } from './lib/command.js';
|
|
7
|
-
import { importAll } from './lib/import_all.js';
|
|
8
|
-
import { Workspace } from './lib/workspace.js';
|
|
9
|
-
|
|
10
|
-
(async () => {
|
|
11
|
-
const { entryPath, localPinstripePath, exists } = await Project.instance;
|
|
12
|
-
const { argv, env, execPath } = process;
|
|
13
|
-
const args = argv.slice(2);
|
|
14
|
-
|
|
15
|
-
if (env.IS_LOCAL_PINSTRIPE != 'true' && localPinstripePath) {
|
|
16
|
-
spawn(execPath, [localPinstripePath, ...args], {
|
|
17
|
-
env: { ...env, IS_LOCAL_PINSTRIPE: 'true' },
|
|
18
|
-
stdio: 'inherit'
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
if(entryPath){
|
|
22
|
-
import(entryPath);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
await importAll();
|
|
26
|
-
|
|
27
|
-
if(exists){
|
|
28
|
-
Command.unregister('generate-project');
|
|
29
|
-
} else {
|
|
30
|
-
const allowedCommands = ['generate-project', 'list-commands'];
|
|
31
|
-
Command.names.forEach(commandName => {
|
|
32
|
-
if(!allowedCommands.includes(commandName)){
|
|
33
|
-
Command.unregister(commandName);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
await Workspace.run(async function(){
|
|
40
|
-
await this.runCommand(...args);
|
|
41
|
-
});
|
|
42
|
-
} catch(e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})();
|
package/lib/class.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export class Class {
|
|
3
|
-
|
|
4
|
-
static extend(){
|
|
5
|
-
return class extends this {};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static include(...includes){
|
|
9
|
-
includes.forEach(include => {
|
|
10
|
-
if(typeof include.meta == 'function') include.meta.call(this);
|
|
11
|
-
this.prototype.assignProps(include, name => name != 'meta');
|
|
12
|
-
});
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static assignProps(...sources){
|
|
17
|
-
return assignProps(this, ...sources);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static new(...args){
|
|
21
|
-
return new this(...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get parent(){
|
|
25
|
-
return this.__proto__;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
constructor(...args){
|
|
29
|
-
let out = this.initialize(...args);
|
|
30
|
-
if(typeof out?.then == 'function'){
|
|
31
|
-
return out.then(out => out || this);
|
|
32
|
-
}
|
|
33
|
-
return out || this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
initialize(){
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
assignProps(...sources){
|
|
41
|
-
return assignProps(this, ...sources);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const assignProps = (target, ...sources) => {
|
|
46
|
-
const fn = typeof sources[sources.length - 1] == 'function' ? sources.pop() : () => true;
|
|
47
|
-
|
|
48
|
-
sources.forEach(source => {
|
|
49
|
-
Object.getOwnPropertyNames(source).forEach(name => {
|
|
50
|
-
if(!fn(name)){
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const descriptor = { ...Object.getOwnPropertyDescriptor(source, name) };
|
|
54
|
-
const { get: targetGet, set: targetSet } = (Object.getOwnPropertyDescriptor(target, name) || {});
|
|
55
|
-
const { get = targetGet, set = targetSet } = descriptor;
|
|
56
|
-
|
|
57
|
-
if(get) descriptor.get = get;
|
|
58
|
-
if(set) descriptor.set = set;
|
|
59
|
-
|
|
60
|
-
Object.defineProperty(target, name, descriptor);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
return target;
|
|
64
|
-
};
|
package/lib/client.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url';
|
|
2
|
-
|
|
3
|
-
import { Class } from "./class.js";
|
|
4
|
-
import { Singleton } from "./singleton.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const Client = Class.extend().include({
|
|
8
|
-
meta(){
|
|
9
|
-
this.include(Singleton);
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
initialize(){
|
|
13
|
-
this.modules = [];
|
|
14
|
-
|
|
15
|
-
this.addModule(`import ${JSON.stringify(fileURLToPath(`${import.meta.url}/../index.js`))};`);
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
addModule(...modules){
|
|
19
|
-
this.modules.push(...modules);
|
|
20
|
-
}
|
|
21
|
-
});
|
package/lib/command.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Class } from './class.js';
|
|
3
|
-
import { Registry } from './registry.js';
|
|
4
|
-
import { ServiceConsumer } from './service_consumer.js';
|
|
5
|
-
import { inflector } from "./inflector.js";
|
|
6
|
-
|
|
7
|
-
export const Command = Class.extend().include({
|
|
8
|
-
meta(){
|
|
9
|
-
this.include(Registry);
|
|
10
|
-
this.include(ServiceConsumer);
|
|
11
|
-
|
|
12
|
-
this.assignProps({
|
|
13
|
-
normalizeName: (...args) => inflector.dasherize(...args),
|
|
14
|
-
|
|
15
|
-
get schedules(){
|
|
16
|
-
if(!this.hasOwnProperty('_schedules')){
|
|
17
|
-
this._schedules = [];
|
|
18
|
-
}
|
|
19
|
-
return this._schedules;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
schedule(...args){
|
|
23
|
-
this.schedules.push(args);
|
|
24
|
-
return this;
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
async run(context, name = 'list-commands', ...args){
|
|
28
|
-
return context.fork().run(async context => {
|
|
29
|
-
context.args = [ ...args ];
|
|
30
|
-
await this.create(name, context).run();
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
run(){
|
|
37
|
-
console.error(`No such command "${this.constructor.name}" exists.`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Command as default } from 'pinstripe';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async run(){
|
|
5
|
-
const [ name = '' ] = this.args;
|
|
6
|
-
const normalizedName = this.inflector.snakeify(name);
|
|
7
|
-
if(normalizedName == ''){
|
|
8
|
-
console.error('A command name must be given.');
|
|
9
|
-
process.exit();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { inProjectRootDir, generateFile, line, indent } = this.fsBuilder;
|
|
13
|
-
|
|
14
|
-
await inProjectRootDir(async () => {
|
|
15
|
-
|
|
16
|
-
await generateFile(`lib/commands/_file_importer.js`, { skipIfExists: true }, () => {
|
|
17
|
-
line();
|
|
18
|
-
line(`export { Command as default } from 'pinstripe';`);
|
|
19
|
-
line();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
await generateFile(`lib/commands/${normalizedName}.js`, () => {
|
|
23
|
-
line();
|
|
24
|
-
line(`export default {`);
|
|
25
|
-
indent(() => {
|
|
26
|
-
line('run(){');
|
|
27
|
-
indent(() => {
|
|
28
|
-
line(`console.log('${this.inflector.dasherize(normalizedName)} command coming soon!')`);
|
|
29
|
-
});
|
|
30
|
-
line('}');
|
|
31
|
-
});
|
|
32
|
-
line('};');
|
|
33
|
-
line();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
async run(){
|
|
4
|
-
const [ name = '' ] = this.args;
|
|
5
|
-
const normalizedName = this.inflector.snakeify(name);
|
|
6
|
-
if(normalizedName == ''){
|
|
7
|
-
console.error('A node wrapper name must be given.');
|
|
8
|
-
process.exit();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { inProjectRootDir, generateFile, line, indent } = this.fsBuilder;
|
|
12
|
-
|
|
13
|
-
await inProjectRootDir(async () => {
|
|
14
|
-
|
|
15
|
-
await generateFile(`lib/components/_file_importer.js`, { skipIfExists: true }, () => {
|
|
16
|
-
line();
|
|
17
|
-
line(`export { Component as default } from 'pinstripe';`);
|
|
18
|
-
line();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
await generateFile(`lib/components/${normalizedName}.js`, () => {
|
|
22
|
-
line();
|
|
23
|
-
line(`export default {`);
|
|
24
|
-
indent(() => {
|
|
25
|
-
line(`initialize(){`);
|
|
26
|
-
indent(() => {
|
|
27
|
-
line(`this.constructor.parent.prototype.initialize.call(this, ...args);`);
|
|
28
|
-
});
|
|
29
|
-
line(`}`);
|
|
30
|
-
});
|
|
31
|
-
line('};');
|
|
32
|
-
line();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
async run(){
|
|
4
|
-
const { extractArg, extractFields, extractOptions } = this.cliUtils;
|
|
5
|
-
|
|
6
|
-
const suffix = this.inflector.snakeify(extractArg('migration'));
|
|
7
|
-
const fields = extractFields();
|
|
8
|
-
const { table } = extractOptions({
|
|
9
|
-
table: (() => {
|
|
10
|
-
const matches = suffix.match(/_to_(.+)$/);
|
|
11
|
-
if(matches){
|
|
12
|
-
return matches[1];
|
|
13
|
-
}
|
|
14
|
-
})()
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const unixTime = Math.floor(new Date().getTime() / 1000);
|
|
18
|
-
const name = `${unixTime}_${suffix}`;
|
|
19
|
-
|
|
20
|
-
const { inProjectRootDir, generateFile, line, indent } = this.fsBuilder;
|
|
21
|
-
|
|
22
|
-
await inProjectRootDir(async () => {
|
|
23
|
-
|
|
24
|
-
await generateFile(`lib/migrations/_file_importer.js`, { skipIfExists: true }, () => {
|
|
25
|
-
line();
|
|
26
|
-
line(`export { Migration as default } from 'pinstripe/database';`);
|
|
27
|
-
line();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
await generateFile(`lib/migrations/${name}.js`, () => {
|
|
31
|
-
line();
|
|
32
|
-
line(`export default async ({ database }) => {`);
|
|
33
|
-
indent(() => {
|
|
34
|
-
line();
|
|
35
|
-
if(table && fields.length){
|
|
36
|
-
fields.forEach(({ name, type }) => {
|
|
37
|
-
line(`await database.${table}.addColumn('${name}', '${type}');`);
|
|
38
|
-
});
|
|
39
|
-
line();
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
line('};');
|
|
43
|
-
line();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
async run(){
|
|
4
|
-
|
|
5
|
-
const { extractArg, extractFields } = this.cliUtils;
|
|
6
|
-
const name = this.inflector.snakeify(extractArg(''));
|
|
7
|
-
if(name == ''){
|
|
8
|
-
console.error('A model name must be given.');
|
|
9
|
-
process.exit();
|
|
10
|
-
}
|
|
11
|
-
const fields = extractFields();
|
|
12
|
-
|
|
13
|
-
const collectionName = this.inflector.camelize(this.inflector.pluralize(name));
|
|
14
|
-
if(!await this.database[collectionName].exists){
|
|
15
|
-
const denormalizedFields = fields.map(({ mandatory, name, type }) => {
|
|
16
|
-
return `${ mandatory ? '^' : '' }${name}:${type}`
|
|
17
|
-
});
|
|
18
|
-
await this.runCommand('generate-migration', `create_${name}`, ...denormalizedFields, '--table', collectionName)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { inProjectRootDir, generateFile, line, indent } = this.fsBuilder;
|
|
22
|
-
|
|
23
|
-
await inProjectRootDir(async () => {
|
|
24
|
-
|
|
25
|
-
await generateFile(`lib/models/_file_importer.js`, { skipIfExists: true }, () => {
|
|
26
|
-
line();
|
|
27
|
-
line(`export { Row as default } from 'pinstripe/database';`);
|
|
28
|
-
line();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await generateFile(`lib/models/${name}.js`, () => {
|
|
32
|
-
line();
|
|
33
|
-
line(`export default {`);
|
|
34
|
-
indent(() => {
|
|
35
|
-
line();
|
|
36
|
-
});
|
|
37
|
-
line('};');
|
|
38
|
-
line();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|