proscenium 0.1.0.alpha2-x86_64-linux → 0.1.0.alpha4-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +216 -32
  3. data/app/components/react_component.rb +10 -3
  4. data/bin/esbuild +0 -0
  5. data/bin/lightningcss +0 -0
  6. data/config/routes.rb +1 -1
  7. data/lib/proscenium/compilers/esbuild/compile_error.js +147 -0
  8. data/lib/proscenium/compilers/esbuild/css/postcss.js +67 -0
  9. data/lib/proscenium/compilers/esbuild/css_plugin.js +176 -0
  10. data/lib/proscenium/compilers/esbuild/env_plugin.js +6 -4
  11. data/lib/proscenium/compilers/esbuild/http_bundle_plugin.js +53 -0
  12. data/lib/proscenium/compilers/esbuild/import_map.js +59 -0
  13. data/lib/proscenium/compilers/esbuild/resolve_plugin.js +67 -65
  14. data/lib/proscenium/compilers/esbuild/setup_plugin.js +32 -22
  15. data/lib/proscenium/{cli → compilers}/esbuild/solidjs_plugin.js +5 -4
  16. data/lib/proscenium/compilers/esbuild.bench.js +7 -3
  17. data/lib/proscenium/compilers/esbuild.js +93 -19
  18. data/lib/proscenium/css_module.rb +48 -6
  19. data/lib/proscenium/helper.rb +5 -3
  20. data/lib/proscenium/middleware/base.rb +13 -3
  21. data/lib/proscenium/middleware/esbuild.rb +17 -1
  22. data/lib/proscenium/middleware/lightningcss.rb +64 -0
  23. data/lib/proscenium/middleware.rb +7 -19
  24. data/lib/proscenium/phlex.rb +36 -0
  25. data/lib/proscenium/railtie.rb +10 -20
  26. data/lib/proscenium/runtime/auto_reload.js +3 -3
  27. data/lib/proscenium/side_load.rb +14 -40
  28. data/lib/proscenium/utils.js +8 -0
  29. data/lib/proscenium/version.rb +1 -1
  30. data/lib/proscenium/view_component.rb +5 -1
  31. data/lib/proscenium.rb +1 -0
  32. metadata +27 -19
  33. data/bin/parcel_css +0 -0
  34. data/lib/proscenium/cli/argument_error.js +0 -24
  35. data/lib/proscenium/cli/builders/index.js +0 -1
  36. data/lib/proscenium/cli/builders/javascript.js +0 -45
  37. data/lib/proscenium/cli/builders/react.js +0 -60
  38. data/lib/proscenium/cli/builders/solid.js +0 -46
  39. data/lib/proscenium/cli/esbuild/env_plugin.js +0 -21
  40. data/lib/proscenium/cli/esbuild/resolve_plugin.js +0 -136
  41. data/lib/proscenium/cli/js_builder.js +0 -194
  42. data/lib/proscenium/cli/solid.js +0 -15
  43. data/lib/proscenium/cli/utils.js +0 -93
  44. data/lib/proscenium/middleware/parcel_css.rb +0 -37
  45. data/lib/proscenium/runtime/component_manager/index.js +0 -27
  46. data/lib/proscenium/runtime/component_manager/render_component.js +0 -40
  47. data/lib/proscenium/runtime/import_css.js +0 -46
data/lib/proscenium.rb CHANGED
@@ -10,6 +10,7 @@ module Proscenium
10
10
  autoload :SideLoad
11
11
  autoload :CssModule
12
12
  autoload :ViewComponent
13
+ autoload :Phlex
13
14
  autoload :Helper
14
15
  autoload :LinkToHelper
15
16
  autoload :Precompile
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha2
4
+ version: 0.1.0.alpha4
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -64,6 +64,20 @@ dependencies:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '3.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: nokogiri
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.13'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.13'
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: oj
69
83
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +131,7 @@ email:
117
131
  - joel@developwithstyle.com
118
132
  executables:
119
133
  - esbuild
120
- - parcel_css
134
+ - lightningcss
121
135
  extensions: []
122
136
  extra_rdoc_files: []
123
137
  files:
@@ -129,27 +143,22 @@ files:
129
143
  - app/components/application_component.rb
130
144
  - app/components/react_component.rb
131
145
  - bin/esbuild
132
- - bin/parcel_css
146
+ - bin/lightningcss
133
147
  - config/routes.rb
134
148
  - lib/proscenium.rb
135
- - lib/proscenium/cli/argument_error.js
136
- - lib/proscenium/cli/builders/index.js
137
- - lib/proscenium/cli/builders/javascript.js
138
- - lib/proscenium/cli/builders/react.js
139
- - lib/proscenium/cli/builders/solid.js
140
- - lib/proscenium/cli/esbuild/env_plugin.js
141
- - lib/proscenium/cli/esbuild/resolve_plugin.js
142
- - lib/proscenium/cli/esbuild/solidjs_plugin.js
143
- - lib/proscenium/cli/js_builder.js
144
- - lib/proscenium/cli/solid.js
145
- - lib/proscenium/cli/utils.js
146
149
  - lib/proscenium/compiler.js
147
150
  - lib/proscenium/compilers/esbuild.bench.js
148
151
  - lib/proscenium/compilers/esbuild.js
149
152
  - lib/proscenium/compilers/esbuild/argument_error.js
153
+ - lib/proscenium/compilers/esbuild/compile_error.js
154
+ - lib/proscenium/compilers/esbuild/css/postcss.js
155
+ - lib/proscenium/compilers/esbuild/css_plugin.js
150
156
  - lib/proscenium/compilers/esbuild/env_plugin.js
157
+ - lib/proscenium/compilers/esbuild/http_bundle_plugin.js
158
+ - lib/proscenium/compilers/esbuild/import_map.js
151
159
  - lib/proscenium/compilers/esbuild/resolve_plugin.js
152
160
  - lib/proscenium/compilers/esbuild/setup_plugin.js
161
+ - lib/proscenium/compilers/esbuild/solidjs_plugin.js
153
162
  - lib/proscenium/css_module.rb
154
163
  - lib/proscenium/current.rb
155
164
  - lib/proscenium/helper.rb
@@ -157,18 +166,17 @@ files:
157
166
  - lib/proscenium/middleware.rb
158
167
  - lib/proscenium/middleware/base.rb
159
168
  - lib/proscenium/middleware/esbuild.rb
160
- - lib/proscenium/middleware/parcel_css.rb
169
+ - lib/proscenium/middleware/lightningcss.rb
161
170
  - lib/proscenium/middleware/runtime.rb
162
171
  - lib/proscenium/middleware/static.rb
172
+ - lib/proscenium/phlex.rb
163
173
  - lib/proscenium/precompile.rb
164
174
  - lib/proscenium/railtie.rb
165
175
  - lib/proscenium/runtime/auto_reload.js
166
- - lib/proscenium/runtime/component_manager/index.js
167
- - lib/proscenium/runtime/component_manager/render_component.js
168
- - lib/proscenium/runtime/import_css.js
169
176
  - lib/proscenium/runtime/react_shim/index.js
170
177
  - lib/proscenium/runtime/react_shim/package.json
171
178
  - lib/proscenium/side_load.rb
179
+ - lib/proscenium/utils.js
172
180
  - lib/proscenium/version.rb
173
181
  - lib/proscenium/view_component.rb
174
182
  - lib/proscenium/view_component/tag_builder.rb
data/bin/parcel_css DELETED
Binary file
@@ -1,24 +0,0 @@
1
- export default class CliArgumentError extends Error {
2
- static MESSAGES = {
3
- cwdRequired: 'Current working directory is required as first argument.',
4
- entrypointRequired: 'An entry point is required as second argument.',
5
- builderRequired: 'The builder is required as third and final argument.',
6
-
7
- cwdUnknown: ({ cwd }) => `A valid working directory is required - received ${cwd}`,
8
- entrypointUnknown: ({ entrypoint }) =>
9
- `A valid entrypoint is required - received ${entrypoint}`,
10
- builderUnknown: ({ builder }) => `Unknown builder '${builder}'`
11
- }
12
-
13
- constructor(reason, options) {
14
- let message = CliArgumentError.MESSAGES[reason]
15
- if (typeof message === 'function') {
16
- message = message(options)
17
- }
18
-
19
- super(message, options)
20
-
21
- this.reason = reason
22
- this.message = message
23
- }
24
- }
@@ -1 +0,0 @@
1
- export const builderNames = ['javascript', 'react', 'solid']
@@ -1,45 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
-
3
- import envPlugin from '../esbuild/env_plugin.js'
4
- import resolvePlugin from '../esbuild/resolve_plugin.js'
5
-
6
- export default async (cwd, entrypoint) => {
7
- const railsEnv = Deno.env.get('RAILS_ENV')
8
- const isProd = railsEnv === 'production'
9
-
10
- let entrypointIsSourcemap = false
11
- if (/\.js\.map$/.test(entrypoint)) {
12
- entrypoint = entrypoint.replace(/\.map$/, '')
13
- entrypointIsSourcemap = true
14
- }
15
-
16
- const params = {
17
- entryPoints: [entrypoint],
18
- absWorkingDir: cwd,
19
- logLevel: 'error',
20
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
21
- outdir: 'public',
22
- outbase: './',
23
- write: false,
24
- format: 'esm',
25
- minify: isProd,
26
- bundle: true,
27
- plugins: [envPlugin(), resolvePlugin({ debug: false })]
28
- }
29
-
30
- try {
31
- const result = await build(params)
32
-
33
- if (params.sourcemap === 'linked') {
34
- if (entrypointIsSourcemap) {
35
- return result.outputFiles[0].contents
36
- } else {
37
- return result.outputFiles[1].contents
38
- }
39
- } else {
40
- return result.outputFiles[0].contents
41
- }
42
- } finally {
43
- stop()
44
- }
45
- }
@@ -1,60 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
- import { join } from 'std/path/mod.ts'
3
-
4
- import envPlugin from '../esbuild/env_plugin.js'
5
- import resolvePlugin from '../esbuild/resolve_plugin.js'
6
-
7
- export default async (cwd, entrypoint) => {
8
- const railsEnv = Deno.env.get('RAILS_ENV')
9
- const isProd = railsEnv === 'production'
10
-
11
- let entrypointIsSourcemap = false
12
- if (/\.jsx\.map$/.test(entrypoint)) {
13
- entrypoint = entrypoint.replace(/\.map$/, '')
14
- entrypointIsSourcemap = true
15
- }
16
-
17
- const params = {
18
- entryPoints: [entrypoint],
19
- absWorkingDir: cwd,
20
- logLevel: 'error',
21
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
22
- outdir: 'public',
23
- outbase: './',
24
- write: false,
25
- format: 'esm',
26
- minify: isProd,
27
- bundle: true,
28
- // jsxFactory: 'createElement',
29
- // jsxFragment: 'Fragment',
30
- plugins: [envPlugin(), resolvePlugin({ debug: false })]
31
- }
32
-
33
- if (entrypoint.endsWith('.jsx')) {
34
- try {
35
- const stat = Deno.lstatSync(join(cwd, 'lib/react_shim.js'))
36
- if (stat.isFile) {
37
- params.inject = ['./lib/react_shim.js']
38
- }
39
- } catch {
40
- // Safe to swallow as this should only throw if file does not exist.
41
- // TODO: print warning to user
42
- }
43
- }
44
-
45
- try {
46
- const result = await build(params)
47
-
48
- if (params.sourcemap === 'linked') {
49
- if (entrypointIsSourcemap) {
50
- return result.outputFiles[0].contents
51
- } else {
52
- return result.outputFiles[1].contents
53
- }
54
- } else {
55
- return result.outputFiles[0].contents
56
- }
57
- } finally {
58
- stop()
59
- }
60
- }
@@ -1,46 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
-
3
- import envPlugin from '../esbuild/env_plugin.js'
4
- import resolvePlugin from '../esbuild/resolve_plugin.js'
5
- import solidjsPlugin from '../esbuild/solidjs_plugin.js'
6
-
7
- export default async (cwd, entrypoint) => {
8
- const railsEnv = Deno.env.get('RAILS_ENV')
9
- const isProd = railsEnv === 'production'
10
-
11
- let entrypointIsSourcemap = false
12
- if (/\.jsx\.map$/.test(entrypoint)) {
13
- entrypoint = entrypoint.replace(/\.map$/, '')
14
- entrypointIsSourcemap = true
15
- }
16
-
17
- const params = {
18
- entryPoints: [entrypoint],
19
- absWorkingDir: cwd,
20
- logLevel: 'error',
21
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
22
- outdir: 'public',
23
- outbase: './',
24
- write: false,
25
- format: 'esm',
26
- minify: isProd,
27
- bundle: true,
28
- plugins: [envPlugin(), resolvePlugin({ debug: false }), solidjsPlugin({ debug: false })]
29
- }
30
-
31
- try {
32
- const result = await build(params)
33
-
34
- if (params.sourcemap === 'linked') {
35
- if (entrypointIsSourcemap) {
36
- return result.outputFiles[0].contents
37
- } else {
38
- return result.outputFiles[1].contents
39
- }
40
- } else {
41
- return result.outputFiles[0].contents
42
- }
43
- } finally {
44
- stop()
45
- }
46
- }
@@ -1,21 +0,0 @@
1
- import { setup } from '../utils.js'
2
-
3
- export default setup('env', () => {
4
- return {
5
- onResolve: {
6
- filter: /^env$/,
7
- callback({ path }) {
8
- return { path, namespace: 'env' }
9
- }
10
- },
11
-
12
- onLoad: {
13
- filter: /.*/,
14
- namespace: 'env',
15
- callback() {
16
- const env = Deno.env.toObject()
17
- return { loader: 'json', contents: JSON.stringify(env) }
18
- }
19
- }
20
- }
21
- })
@@ -1,136 +0,0 @@
1
- import { join, resolve } from 'std/path/mod.ts'
2
- import {
3
- parseFromString as parseImportMap,
4
- resolve as resolveFromImportMap
5
- } from 'import-maps/resolve'
6
-
7
- import { setup } from '../utils.js'
8
-
9
- const baseURL = new URL('file://')
10
- const importKinds = ['import-statement', 'dynamic-import', 'require-call']
11
-
12
- export default setup('resolve', build => {
13
- const cwd = build.initialOptions.absWorkingDir
14
- const importMap = readImportMap()
15
-
16
- return {
17
- onResolve: {
18
- filter: /.*/,
19
- async callback(args) {
20
- // Remote modules
21
- if (args.path.startsWith('http://') || args.path.startsWith('https://')) {
22
- return { external: true }
23
- }
24
-
25
- // Proscenium runtime
26
- if (args.path.startsWith('/proscenium-runtime')) {
27
- return { external: true }
28
- }
29
-
30
- // Everything else is unbundled.
31
- if (importKinds.includes(args.kind)) {
32
- return await unbundleImport(args)
33
- }
34
- }
35
- },
36
-
37
- onLoad: {
38
- filter: /.*/,
39
- namespace: 'importStylesheet',
40
- callback(args) {
41
- const result = {
42
- resolveDir: cwd,
43
- loader: 'js'
44
- }
45
-
46
- if (args.path.endsWith('.module.css')) {
47
- result.contents = `
48
- import { importCssModule } from '/proscenium-runtime/import_css.js'
49
- export default await importCssModule('${args.path}')
50
- `
51
- } else {
52
- result.contents = `
53
- import { appendStylesheet } from '/proscenium-runtime/import_css.js'
54
- appendStylesheet('${args.path}')
55
- `
56
- }
57
-
58
- return result
59
- }
60
- }
61
- }
62
-
63
- // Resolve the given `params.path` to a path relative to the Rails root.
64
- //
65
- // Examples:
66
- // 'react' -> '/.../node_modules/react/index.js'
67
- // './my_module' -> '/.../app/my_module.js'
68
- // '/app/my_module' -> '/.../app/my_module.js'
69
- async function unbundleImport(params) {
70
- const result = { path: params.path }
71
-
72
- if (importMap) {
73
- const { matched, resolvedImport } = resolveFromImportMap(params.path, importMap, baseURL)
74
- if (matched) {
75
- if (resolvedImport.protocol === 'file:') {
76
- params.path = resolvedImport.pathname
77
- } else {
78
- return { path: resolvedImport.href, external: true }
79
- }
80
- }
81
- }
82
-
83
- // Absolute path - append to current working dir.
84
- if (params.path.startsWith('/')) {
85
- result.path = resolve(cwd, params.path.slice(1))
86
- }
87
-
88
- // Resolve the path using esbuild's internal resolution. This allows us to import node packages
89
- // and extension-less paths without custom code, as esbuild with resolve them for us.
90
- const resolveResult = await build.resolve(result.path, {
91
- resolveDir: params.resolveDir,
92
- pluginData: {
93
- // We use this property later on, as we should ignore this resolution call.
94
- isResolvingPath: true
95
- }
96
- })
97
-
98
- if (resolveResult.errors.length > 0) {
99
- // throw `${resolveResult.errors[0].text} (resolveDir: ${cwd})`
100
- }
101
-
102
- result.path = resolveResult.path.slice(cwd.length)
103
- result.sideEffects = resolveResult.sideEffects
104
-
105
- if (
106
- params.path.endsWith('.css') &&
107
- params.kind === 'import-statement' &&
108
- /\.jsx?$/.test(params.importer)
109
- ) {
110
- // We're importing a CSS file from JS(X).
111
- result.namespace = 'importStylesheet'
112
- } else {
113
- // Requested path is a bare module.
114
- result.external = true
115
- }
116
-
117
- return result
118
- }
119
-
120
- function readImportMap() {
121
- const file = join(cwd, 'config', 'import_map.json')
122
- let source
123
-
124
- try {
125
- source = Deno.readTextFileSync(file)
126
- } catch {
127
- return null
128
- }
129
-
130
- return parseImportMap(source, baseURL)
131
- }
132
- })
133
-
134
- function isBareModule(path) {
135
- return !path.startsWith('.') && !path.startsWith('/')
136
- }
@@ -1,194 +0,0 @@
1
- import * as esbuild from 'https://deno.land/x/esbuild@v0.14.27/mod.js'
2
- import { parse } from 'flags/mod.ts'
3
- import { join } from 'path/mod.ts'
4
-
5
- import resolvePlugin from './esbuild/resolve_plugin.js'
6
-
7
- const isProd = Deno.env.get('RAILS_ENV') === 'production'
8
- const isTest = Deno.env.get('RAILS_ENV') === 'test'
9
- const template = `
10
- <style>
11
- :host {
12
- position: fixed;
13
- z-index: 99999;
14
- top: 0;
15
- left: 0;
16
- width: 100%;
17
- height: 100%;
18
- overflow-y: scroll;
19
- margin: 0;
20
- background: rgba(0, 0, 0, 0.66);
21
- display: flex;
22
- align-items: center;
23
- --monospace: 'SFMono-Regular', Consolas,
24
- 'Liberation Mono', Menlo, Courier, monospace;
25
- --red: #ff5555;
26
- --yellow: #e2aa53;
27
- --purple: #cfa4ff;
28
- --cyan: #2dd9da;
29
- --dim: #c9c9c9;
30
- }
31
-
32
- .window {
33
- font-family: var(--monospace);
34
- line-height: 1.5;
35
- width: 800px;
36
- color: #d8d8d8;
37
- margin: 30px auto;
38
- padding: 25px 40px;
39
- position: relative;
40
- background: #181818;
41
- border-radius: 6px 6px 8px 8px;
42
- box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
43
- overflow: hidden;
44
- border-top: 8px solid var(--red);
45
- }
46
-
47
- pre {
48
- font-family: var(--monospace);
49
- font-size: 16px;
50
- margin-top: 0;
51
- margin-bottom: 1em;
52
- overflow-x: scroll;
53
- scrollbar-width: none;
54
- }
55
-
56
- pre::-webkit-scrollbar {
57
- display: none;
58
- }
59
-
60
- .message {
61
- line-height: 1.3;
62
- font-weight: 600;
63
- white-space: pre-wrap;
64
- }
65
-
66
- .message-body {
67
- color: var(--red);
68
- }
69
-
70
- .file {
71
- color: var(--cyan);
72
- margin-bottom: 0;
73
- white-space: pre-wrap;
74
- word-break: break-all;
75
- }
76
-
77
- </style>
78
- <div class="window">
79
- <pre class="message"><span class="message-body"></span></pre>
80
- <pre class="file"></pre>
81
- </div>
82
- `
83
-
84
- export default async (args, { debug }) => {
85
- const { _: entrypoints, ...flags } = parse(args)
86
- const [cwd, entrypoint] = validatePaths(entrypoints)
87
-
88
- const params = {
89
- entryPoints: [entrypoint],
90
- absWorkingDir: cwd,
91
- logLevel: 'error',
92
- sourcemap: isTest ? false : 'inline',
93
- write: false,
94
- format: 'esm',
95
- // minify: true,
96
- bundle: true,
97
- plugins: [resolvePlugin({ debug })]
98
- }
99
-
100
- if (entrypoint.endsWith('.jsx')) {
101
- try {
102
- const stat = Deno.lstatSync(join(cwd, 'lib/react_shim.js'))
103
- if (stat.isFile) {
104
- params.inject = ['./lib/react_shim.js']
105
- }
106
- } catch {
107
- // Safe to swallow as this should only throw if file does not exist.
108
- }
109
- }
110
-
111
- try {
112
- const result = await esbuild.build(params)
113
- return result.outputFiles[0].contents
114
-
115
- // } catch (e) {
116
- // if (isProd) {
117
- // return new TextEncoder().encode(`
118
- // const err = ${JSON.stringify(e.errors[0])}
119
- // const location = \`\${err.location.file}:\${err.location.line}:\${err.location.column}\`
120
- // console.error('%s at %O', err.text, location);
121
- // `)
122
- // } else {
123
- // return new TextEncoder().encode(`
124
- // class ErrorOverlay extends HTMLElement {
125
- // constructor(err) {
126
- // super()
127
-
128
- // this.root = this.attachShadow({ mode: 'open' })
129
- // this.root.innerHTML = \`${template}\`
130
- // this.root.querySelector('.message-body').textContent = err.text.trim()
131
-
132
- // if (err.location) {
133
- // const location = \`\${err.location.file}:\${err.location.line}:\${err.location.column}\`
134
- // this.root.querySelector('.file').textContent = location
135
- // console.error('%s at %O', err.text, location)
136
- // } else {
137
- // console.error(err.text)
138
- // }
139
-
140
- // throw err
141
- // }
142
- // }
143
-
144
- // customElements.define('error-overlay', ErrorOverlay)
145
- // document.body.appendChild(new ErrorOverlay(${JSON.stringify(e.errors[0])}))
146
- // `)
147
- // }
148
- } finally {
149
- esbuild.stop()
150
- }
151
- }
152
-
153
- function validatePaths(paths) {
154
- const cwd = paths[0]
155
- const entrypoint = paths[1]
156
-
157
- if (!cwd || !entrypoint) {
158
- throw new TypeError(
159
- 'Current working directory and entrypoint are required as first and second arguments.'
160
- )
161
- }
162
-
163
- try {
164
- const stat = Deno.lstatSync(cwd)
165
- if (!stat.isDirectory) {
166
- throw new TypeError(
167
- `Current working directory is required as the first argument - received ${cwd}`
168
- )
169
- }
170
- } catch {
171
- throw new TypeError(
172
- `A valid working directory is required as the first argument - received ${cwd}`
173
- )
174
- }
175
-
176
- try {
177
- const stat = Deno.lstatSync(join(cwd, entrypoint))
178
- if (!stat.isFile) {
179
- throw new TypeError(`Entrypoint is required as the second argument - received ${entrypoint}`)
180
- }
181
- } catch {
182
- throw new TypeError(
183
- `A valid entrypoint is required as the second argument - received ${entrypoint}`
184
- )
185
- }
186
-
187
- if (/\.(js|jsx)$/.test(entrypoint) === false) {
188
- throw new TypeError(
189
- `Only a JS/JSX entrypoint is supported with this CLI - received ${entrypoint}`
190
- )
191
- }
192
-
193
- return [cwd, entrypoint]
194
- }
@@ -1,15 +0,0 @@
1
- import { writeAll } from 'std/streams/mod.ts'
2
- import { parseArgs } from './utils.js'
3
-
4
- import builder from './builders/solid.js'
5
-
6
- if (import.meta.main) {
7
- await writeAll(Deno.stdout, await main(Deno.args))
8
- }
9
-
10
- async function main(args = []) {
11
- const [cwd, entrypoint, _] = parseArgs(args)
12
- return await builder(cwd, entrypoint)
13
- }
14
-
15
- export default main