pinstripe 0.35.0 → 0.36.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.
Files changed (135) hide show
  1. package/README.md +1 -1
  2. package/cli.js +53 -0
  3. package/lib/annotatable.js +1 -0
  4. package/lib/bundle.js +95 -0
  5. package/lib/class.js +1 -1
  6. package/lib/command.js +13 -0
  7. package/lib/command.test.js +70 -0
  8. package/lib/commands/_file_importer.js +1 -0
  9. package/lib/commands/generate_command.js +42 -0
  10. package/lib/commands/generate_job.js +50 -0
  11. package/lib/commands/generate_project.js +178 -0
  12. package/lib/commands/generate_service.js +38 -0
  13. package/lib/commands/generate_view.js +83 -0
  14. package/lib/commands/initialize_project.js +6 -0
  15. package/lib/commands/list_jobs.js +21 -0
  16. package/lib/commands/list_services.js +21 -0
  17. package/lib/commands/list_views.js +22 -0
  18. package/lib/commands/run_job.js +15 -0
  19. package/lib/commands/show_config.js +12 -0
  20. package/lib/commands/show_theme.js +11 -0
  21. package/lib/commands/start_repl.js +12 -0
  22. package/lib/commands/start_server.js +57 -0
  23. package/lib/component.js +1 -767
  24. package/lib/constants.js +1 -1
  25. package/lib/context.js +2 -0
  26. package/lib/defer.js +2 -0
  27. package/lib/html.js +72 -0
  28. package/lib/import_all.js +9 -0
  29. package/lib/importable_registry.js +2 -0
  30. package/lib/index.js +11 -0
  31. package/lib/inflector.js +1 -1
  32. package/lib/initialize.js +23 -14
  33. package/lib/job.js +43 -0
  34. package/lib/json.js +47 -0
  35. package/lib/json.test.js +399 -0
  36. package/lib/lru_cache.js +1 -1
  37. package/lib/missing_resource_error.js +2 -0
  38. package/lib/model.js +72 -0
  39. package/lib/project.js +70 -0
  40. package/lib/registry.js +1 -1
  41. package/lib/service_factory.js +20 -0
  42. package/lib/service_file_importers/js.js +49 -0
  43. package/lib/services/_file_importer.js +1 -0
  44. package/lib/services/bundler.js +11 -0
  45. package/lib/services/call_handler.js +94 -0
  46. package/lib/services/config.js +84 -0
  47. package/lib/services/cookies.js +18 -0
  48. package/lib/services/create_model.js +8 -0
  49. package/lib/services/css_classes_for.js +13 -0
  50. package/lib/services/defer.js +12 -0
  51. package/lib/services/environment.js +24 -0
  52. package/lib/services/feature_flags.js +32 -0
  53. package/lib/services/format_date.js +8 -0
  54. package/lib/services/fs_builder.js +94 -0
  55. package/lib/services/inflector.js +8 -0
  56. package/lib/services/initial_params.js +14 -0
  57. package/lib/services/is_client.js +10 -0
  58. package/lib/services/job_coordinator.js +20 -0
  59. package/lib/services/job_queue.js +20 -0
  60. package/lib/services/job_scheduler.js +70 -0
  61. package/lib/services/job_worker.js +47 -0
  62. package/lib/services/params.js +14 -0
  63. package/lib/services/parse_html.js +8 -0
  64. package/lib/services/project.js +8 -0
  65. package/lib/services/render_form.js +147 -0
  66. package/lib/services/render_html.js +12 -0
  67. package/lib/services/render_json.js +12 -0
  68. package/lib/services/render_redirect.js +5 -0
  69. package/lib/services/render_table.js +48 -0
  70. package/lib/services/render_tag.js +26 -0
  71. package/lib/services/render_text.js +8 -0
  72. package/lib/services/render_view.js +16 -0
  73. package/lib/services/repl.js +54 -0
  74. package/lib/services/run_command.js +8 -0
  75. package/lib/services/run_in_new_workspace.js +18 -0
  76. package/lib/services/run_job.js +9 -0
  77. package/lib/services/send_mail.js +64 -0
  78. package/lib/services/server.js +227 -0
  79. package/lib/services/service_manager.js +12 -0
  80. package/lib/services/service_worker.js +99 -0
  81. package/lib/services/theme.js +11 -0
  82. package/lib/services/trapify.js +8 -0
  83. package/lib/services/version.js +27 -0
  84. package/lib/services/view.js +6 -0
  85. package/lib/services/view_map.js +83 -0
  86. package/lib/services/view_map.test.js +36 -0
  87. package/lib/singleton.js +2 -0
  88. package/lib/text.js +10 -0
  89. package/lib/theme.js +75 -0
  90. package/lib/theme.test.js +30 -0
  91. package/lib/theme_default_design_tokens.js +455 -0
  92. package/lib/trapify.js +1 -1
  93. package/lib/validateable.js +2 -0
  94. package/lib/validation_error.js +2 -0
  95. package/lib/view.js +132 -0
  96. package/lib/view_file_importers/js.js +62 -0
  97. package/lib/views/_file_importer.js +1 -0
  98. package/lib/views/_pinstripe/_button.js +154 -0
  99. package/lib/views/_pinstripe/_content.js +256 -0
  100. package/lib/views/_pinstripe/_form.js +301 -0
  101. package/lib/views/_pinstripe/_pagination.js +47 -0
  102. package/lib/views/_pinstripe/_panel.js +69 -0
  103. package/lib/views/_pinstripe/_shell/environment.json.js +8 -0
  104. package/lib/views/_pinstripe/_shell/feature_flags.json.js +8 -0
  105. package/lib/views/_pinstripe/_shell/index.js +206 -0
  106. package/lib/views/_pinstripe/_shell/service_worker.js.map.js +7 -0
  107. package/lib/views/_pinstripe/_shell/styles.css.js +61 -0
  108. package/lib/views/_pinstripe/_shell/version.json.js +8 -0
  109. package/lib/views/_pinstripe/_shell/window.js.js +7 -0
  110. package/lib/views/_pinstripe/_shell/window.js.map.js +7 -0
  111. package/lib/views/_pinstripe/_table.js +139 -0
  112. package/lib/views/_placeholders/overlay.js +55 -0
  113. package/lib/views/service_worker.js.js +7 -0
  114. package/lib/views/up.js +11 -0
  115. package/lib/virtual_node.js +1 -1
  116. package/lib/workspace.js +4 -0
  117. package/package.json +32 -8
  118. package/lib/component_event.js +0 -28
  119. package/lib/components/helpers.js +0 -74
  120. package/lib/components/index.js +0 -15
  121. package/lib/components/pinstripe_anchor.js +0 -25
  122. package/lib/components/pinstripe_body.js +0 -42
  123. package/lib/components/pinstripe_document.js +0 -114
  124. package/lib/components/pinstripe_form.js +0 -65
  125. package/lib/components/pinstripe_frame.js +0 -86
  126. package/lib/components/pinstripe_global_styles.js +0 -13
  127. package/lib/components/pinstripe_menu.js +0 -33
  128. package/lib/components/pinstripe_modal.js +0 -165
  129. package/lib/components/pinstripe_overlay.js +0 -51
  130. package/lib/components/pinstripe_popover.js +0 -86
  131. package/lib/components/pinstripe_progress_bar.js +0 -78
  132. package/lib/components/pinstripe_redirect.js +0 -18
  133. package/lib/components/pinstripe_script.js +0 -12
  134. package/lib/components/pinstripe_skeleton.js +0 -57
  135. package/lib/proof_of_work.js +0 -2
@@ -0,0 +1,21 @@
1
+
2
+ import chalk from 'chalk';
3
+ import { ServiceFactory } from 'pinstripe';
4
+
5
+ export default {
6
+ meta(){
7
+ this.assignProps({
8
+ description: 'Lists all available services in the current project.'
9
+ });
10
+ },
11
+
12
+ run(){
13
+ console.log('');
14
+ console.log('The following services are available:');
15
+ console.log('');
16
+ ServiceFactory.names.forEach(serviceFactoryName => {
17
+ console.log(` * ${chalk.green(serviceFactoryName)}`);
18
+ });
19
+ console.log('');
20
+ }
21
+ };
@@ -0,0 +1,22 @@
1
+
2
+ import chalk from 'chalk';
3
+ import { View } from 'pinstripe';
4
+
5
+ export default {
6
+ meta(){
7
+ this.assignProps({
8
+ description: 'Lists all available views in the current project.'
9
+ });
10
+ },
11
+
12
+ run(){
13
+ console.log('');
14
+ console.log(`The following views are available:`);
15
+ console.log('');
16
+ View.names.forEach(viewName => {
17
+ console.log(` * ${chalk.green(viewName)}`);
18
+ });
19
+ console.log('');
20
+ }
21
+ };
22
+
@@ -0,0 +1,15 @@
1
+
2
+ export default {
3
+ meta(){
4
+ this.assignProps({
5
+ description: 'Runs a job by name from the lib/jobs directory.'
6
+ });
7
+
8
+ this.hasParam('name', { type: 'string', alias: 'arg1', description: 'The name of the job to run (in snake_case).' });
9
+ },
10
+
11
+ async run(){
12
+ const normalizedName = this.inflector.snakeify(this.params.name);
13
+ this.runJob(normalizedName);
14
+ }
15
+ };
@@ -0,0 +1,12 @@
1
+
2
+ export default {
3
+ meta(){
4
+ this.assignProps({
5
+ description: 'Displays the current project configuration in JSON format.'
6
+ });
7
+ },
8
+
9
+ async run(){
10
+ console.log(JSON.stringify(await this.config, null, 2));
11
+ }
12
+ };
@@ -0,0 +1,11 @@
1
+ export default {
2
+ meta(){
3
+ this.assignProps({
4
+ description: 'Displays the current project theme configuration in JSON format.'
5
+ });
6
+ },
7
+
8
+ async run() {
9
+ console.log(JSON.stringify(await this.theme, null, 2));
10
+ },
11
+ };
@@ -0,0 +1,12 @@
1
+
2
+ export default {
3
+ meta(){
4
+ this.assignProps({
5
+ description: 'Starts an interactive REPL (Read-Eval-Print Loop) session for the project.'
6
+ });
7
+ },
8
+
9
+ async run(){
10
+ await this.repl.start();
11
+ }
12
+ };
@@ -0,0 +1,57 @@
1
+
2
+ export default {
3
+ meta(){
4
+ this.assignProps({
5
+ description: 'Starts the web server and optionally the job worker.'
6
+ });
7
+
8
+ this.hasParam('host', {
9
+ type: 'string',
10
+ optional: true,
11
+ description: 'Host and port configuration (e.g. "127.0.0.1:3000"). Defaults to PINSTRIPE_HOST environment variable or "127.0.0.1:3000".'
12
+ });
13
+
14
+ this.hasParam('withoutJobs', {
15
+ type: 'boolean',
16
+ optional: true,
17
+ description: 'Skip starting the job worker.'
18
+ });
19
+ },
20
+
21
+ async run(){
22
+ await this.runHook('beforeServerStart');
23
+
24
+ const {
25
+ host = process.env.PINSTRIPE_HOST || '127.0.0.1:3000',
26
+ withoutJobs = false
27
+ } = this.params;
28
+
29
+ for(let pair of host.trim().split(/\s+/)){
30
+ const matches = pair.match(/^([^:]+):(\d+)$/);
31
+ const hostname = matches ? matches[1] : host;
32
+ const port = matches ? matches[2] : port;
33
+
34
+ this.server.start({
35
+ port: parseInt(port),
36
+ hostname
37
+ });
38
+ }
39
+
40
+ if(!withoutJobs){
41
+ this.jobCoordinator.start();
42
+ }
43
+
44
+ await this.runHook('afterServerStart');
45
+
46
+ // Keep the command running to prevent context destruction.
47
+ // This ensures the database connection stays alive for background services.
48
+ await new Promise((resolve) => {
49
+ const shutdown = async () => {
50
+ await this.runHook('beforeServerStop');
51
+ resolve();
52
+ };
53
+ process.on('SIGINT', shutdown);
54
+ process.on('SIGTERM', shutdown);
55
+ });
56
+ }
57
+ };