@adonisjs/assembler 5.9.4 → 6.0.0-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/LICENSE.md +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/src/bundler.d.ts +10 -0
- package/build/src/bundler.js +133 -0
- package/build/src/dev_server.d.ts +13 -0
- package/build/src/dev_server.js +189 -0
- package/build/src/run.d.ts +3 -0
- package/build/src/run.js +19 -0
- package/build/src/types.d.ts +26 -0
- package/build/src/watch.d.ts +8 -0
- package/build/src/watch.js +18 -0
- package/package.json +77 -99
- package/build/ace-manifest.json +0 -521
- package/build/commands/Build.d.ts +0 -37
- package/build/commands/Build.js +0 -138
- package/build/commands/Invoke.d.ts +0 -34
- package/build/commands/Invoke.js +0 -234
- package/build/commands/Make/Base.d.ts +0 -30
- package/build/commands/Make/Base.js +0 -75
- package/build/commands/Make/Command.d.ts +0 -35
- package/build/commands/Make/Command.js +0 -82
- package/build/commands/Make/Controller.d.ts +0 -37
- package/build/commands/Make/Controller.js +0 -89
- package/build/commands/Make/Exception.d.ts +0 -32
- package/build/commands/Make/Exception.js +0 -75
- package/build/commands/Make/Listener.d.ts +0 -30
- package/build/commands/Make/Listener.js +0 -70
- package/build/commands/Make/Middleware.d.ts +0 -31
- package/build/commands/Make/Middleware.js +0 -87
- package/build/commands/Make/PreloadFile.d.ts +0 -38
- package/build/commands/Make/PreloadFile.js +0 -157
- package/build/commands/Make/Provider.d.ts +0 -31
- package/build/commands/Make/Provider.js +0 -114
- package/build/commands/Make/Suite.d.ts +0 -41
- package/build/commands/Make/Suite.js +0 -120
- package/build/commands/Make/Test.d.ts +0 -35
- package/build/commands/Make/Test.js +0 -96
- package/build/commands/Make/Validator.d.ts +0 -31
- package/build/commands/Make/Validator.js +0 -71
- package/build/commands/Make/View.d.ts +0 -30
- package/build/commands/Make/View.js +0 -70
- package/build/commands/Serve.d.ts +0 -33
- package/build/commands/Serve.js +0 -112
- package/build/commands/Test.d.ts +0 -57
- package/build/commands/Test.js +0 -159
- package/build/commands/TypeCheck.d.ts +0 -16
- package/build/commands/TypeCheck.js +0 -85
- package/build/config/paths.d.ts +0 -7
- package/build/config/paths.js +0 -18
- package/build/register.js +0 -15
- package/build/src/AssetsBundler/index.d.ts +0 -76
- package/build/src/AssetsBundler/index.js +0 -216
- package/build/src/Compiler/index.d.ts +0 -62
- package/build/src/Compiler/index.js +0 -287
- package/build/src/Contracts/index.d.ts +0 -8
- package/build/src/Contracts/index.js +0 -10
- package/build/src/DevServer/index.d.ts +0 -70
- package/build/src/DevServer/index.js +0 -306
- package/build/src/EnvParser/index.d.ts +0 -21
- package/build/src/EnvParser/index.js +0 -48
- package/build/src/HttpServer/index.d.ts +0 -34
- package/build/src/HttpServer/index.js +0 -87
- package/build/src/Manifest/index.d.ts +0 -32
- package/build/src/Manifest/index.js +0 -88
- package/build/src/RcFile/index.d.ts +0 -72
- package/build/src/RcFile/index.js +0 -174
- package/build/src/Test/index.d.ts +0 -75
- package/build/src/Test/index.js +0 -346
- package/build/src/Test/process.d.ts +0 -22
- package/build/src/Test/process.js +0 -68
- package/build/src/Ts/index.d.ts +0 -24
- package/build/src/Ts/index.js +0 -55
- package/build/src/requireHook/index.d.ts +0 -5
- package/build/src/requireHook/index.js +0 -28
- package/build/src/requireHook/ioc-transformer.d.ts +0 -6
- package/build/src/requireHook/ioc-transformer.js +0 -21
- package/build/templates/command.txt +0 -33
- package/build/templates/controller.txt +0 -3
- package/build/templates/event-listener.txt +0 -3
- package/build/templates/exception.txt +0 -15
- package/build/templates/middleware.txt +0 -8
- package/build/templates/preload-file.txt +0 -9
- package/build/templates/provider.txt +0 -40
- package/build/templates/resource-controller.txt +0 -17
- package/build/templates/self-handle-exception.txt +0 -32
- package/build/templates/test-entrypoint.txt +0 -45
- package/build/templates/test.txt +0 -5
- package/build/templates/tests/bootstrap.txt +0 -69
- package/build/templates/tests/functional/hello_world_api.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_slim.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_web.spec.txt +0 -8
- package/build/templates/tests-contract.txt +0 -18
- package/build/templates/validator.txt +0 -40
- package/build/templates/view.txt +0 -0
- package/build/templates/webpack.config.txt +0 -214
- /package/build/{register.d.ts → src/types.js} +0 -0
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright (c) 2023 AdonisJS Framework
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { type Logger } from '@poppinss/cliui';
|
|
4
|
+
import type { BundlerOptions } from './types.js';
|
|
5
|
+
export declare class Bundler {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(cwd: URL, ts: typeof tsStatic, options: BundlerOptions);
|
|
8
|
+
setLogger(logger: Logger): this;
|
|
9
|
+
bundle(stopOnError?: boolean, client?: 'npm' | 'yarn' | 'pnpm'): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import slash from 'slash';
|
|
3
|
+
import copyfiles from 'cpy';
|
|
4
|
+
import { execa } from 'execa';
|
|
5
|
+
import { join, relative } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { ConfigParser } from '@poppinss/chokidar-ts';
|
|
8
|
+
import { cliui } from '@poppinss/cliui';
|
|
9
|
+
const ui = cliui();
|
|
10
|
+
export class Bundler {
|
|
11
|
+
#cwd;
|
|
12
|
+
#cwdPath;
|
|
13
|
+
#ts;
|
|
14
|
+
#logger = ui.logger;
|
|
15
|
+
#options;
|
|
16
|
+
get #colors() {
|
|
17
|
+
return this.#logger.getColors();
|
|
18
|
+
}
|
|
19
|
+
constructor(cwd, ts, options) {
|
|
20
|
+
this.#cwd = cwd;
|
|
21
|
+
this.#cwdPath = fileURLToPath(this.#cwd);
|
|
22
|
+
this.#ts = ts;
|
|
23
|
+
this.#options = options;
|
|
24
|
+
}
|
|
25
|
+
#getRelativeName(filePath) {
|
|
26
|
+
return slash(relative(this.#cwdPath, filePath));
|
|
27
|
+
}
|
|
28
|
+
async #cleanupBuildDirectory(outDir) {
|
|
29
|
+
await fs.remove(outDir);
|
|
30
|
+
}
|
|
31
|
+
async #runTsc() {
|
|
32
|
+
try {
|
|
33
|
+
await execa('tsc', [], {
|
|
34
|
+
cwd: this.#cwd,
|
|
35
|
+
preferLocal: true,
|
|
36
|
+
localDir: this.#cwd,
|
|
37
|
+
windowsHide: false,
|
|
38
|
+
buffer: false,
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
});
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async #copyFiles(files, outDir) {
|
|
48
|
+
try {
|
|
49
|
+
await copyfiles(files, outDir, { cwd: this.#cwdPath });
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (!error.message.includes("the file doesn't exist")) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async #copyMetaFiles(outDir, additionalFilesToCopy) {
|
|
58
|
+
const metaFiles = (this.#options.metaFiles || [])
|
|
59
|
+
.map((file) => file.pattern)
|
|
60
|
+
.concat(additionalFilesToCopy);
|
|
61
|
+
await this.#copyFiles(metaFiles, outDir);
|
|
62
|
+
}
|
|
63
|
+
async #copyAdonisRcFile(outDir) {
|
|
64
|
+
const existingContents = await fs.readJSON(join(this.#cwdPath, '.adonisrc.json'));
|
|
65
|
+
const compiledContents = Object.assign({}, existingContents, {
|
|
66
|
+
typescript: false,
|
|
67
|
+
lastCompiledAt: new Date().toISOString(),
|
|
68
|
+
});
|
|
69
|
+
await fs.outputJSON(join(outDir, '.adonisrc.json'), compiledContents, { spaces: 2 });
|
|
70
|
+
}
|
|
71
|
+
#getClientLockFile(client) {
|
|
72
|
+
switch (client) {
|
|
73
|
+
case 'npm':
|
|
74
|
+
return 'package-lock.json';
|
|
75
|
+
case 'yarn':
|
|
76
|
+
return 'yarn.lock';
|
|
77
|
+
case 'pnpm':
|
|
78
|
+
return 'pnpm-lock.yaml';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
#getClientInstallCommand(client) {
|
|
82
|
+
switch (client) {
|
|
83
|
+
case 'npm':
|
|
84
|
+
return 'npm ci --omit="dev"';
|
|
85
|
+
case 'yarn':
|
|
86
|
+
return 'yarn install --production';
|
|
87
|
+
case 'pnpm':
|
|
88
|
+
return 'pnpm i --prod';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setLogger(logger) {
|
|
92
|
+
this.#logger = logger;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
async bundle(stopOnError = true, client = 'npm') {
|
|
96
|
+
const { config } = new ConfigParser(this.#cwd, 'tsconfig.json', this.#ts).parse();
|
|
97
|
+
if (!config) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const outDir = config.options.outDir || fileURLToPath(new URL('build/', this.#cwd));
|
|
101
|
+
this.#logger.info('cleaning up output directory', { suffix: this.#getRelativeName(outDir) });
|
|
102
|
+
await this.#cleanupBuildDirectory(outDir);
|
|
103
|
+
this.#logger.info('compiling typescript source', { suffix: 'tsc' });
|
|
104
|
+
const buildCompleted = await this.#runTsc();
|
|
105
|
+
await this.#copyFiles(['ace.js'], outDir);
|
|
106
|
+
if (!buildCompleted && stopOnError) {
|
|
107
|
+
await this.#cleanupBuildDirectory(outDir);
|
|
108
|
+
const instructions = ui
|
|
109
|
+
.sticker()
|
|
110
|
+
.fullScreen()
|
|
111
|
+
.drawBorder((borderChar, colors) => colors.red(borderChar));
|
|
112
|
+
instructions.add(this.#colors.red('Cannot complete the build process as there are TypeScript errors.'));
|
|
113
|
+
instructions.add(this.#colors.red('Use "--ignore-ts-errors" flag to ignore TypeScript errors and continue the build.'));
|
|
114
|
+
this.#logger.logError(instructions.prepare());
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const pkgFiles = ['package.json', this.#getClientLockFile(client)];
|
|
118
|
+
this.#logger.info('copying meta files to the output directory');
|
|
119
|
+
await this.#copyMetaFiles(outDir, pkgFiles);
|
|
120
|
+
this.#logger.info('copying .adonisrc.json file to the output directory');
|
|
121
|
+
await this.#copyAdonisRcFile(outDir);
|
|
122
|
+
this.#logger.success('build completed');
|
|
123
|
+
this.#logger.log('');
|
|
124
|
+
ui.instructions()
|
|
125
|
+
.useRenderer(this.#logger.getRenderer())
|
|
126
|
+
.heading('Run the following commands to start the server in production')
|
|
127
|
+
.add(this.#colors.cyan(`cd ${this.#getRelativeName(outDir)}`))
|
|
128
|
+
.add(this.#colors.cyan(this.#getClientInstallCommand(client)))
|
|
129
|
+
.add(this.#colors.cyan('node bin/server.js'))
|
|
130
|
+
.render();
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { type Logger } from '@poppinss/cliui';
|
|
4
|
+
import type { DevServerOptions } from './types.js';
|
|
5
|
+
export declare class DevServer {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(cwd: URL, options: DevServerOptions);
|
|
8
|
+
setLogger(logger: Logger): this;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
startAndWatch(ts: typeof tsStatic, options?: {
|
|
11
|
+
poll: boolean;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import getPort from 'get-port';
|
|
2
|
+
import picomatch from 'picomatch';
|
|
3
|
+
import { cliui } from '@poppinss/cliui';
|
|
4
|
+
import { EnvLoader, EnvParser } from '@adonisjs/env';
|
|
5
|
+
import { run } from './run.js';
|
|
6
|
+
import { watch } from './watch.js';
|
|
7
|
+
const ui = cliui();
|
|
8
|
+
export class DevServer {
|
|
9
|
+
#cwd;
|
|
10
|
+
#logger = ui.logger;
|
|
11
|
+
#options;
|
|
12
|
+
#isWatching = false;
|
|
13
|
+
#scriptFile = 'bin/server.js';
|
|
14
|
+
#httpServerProcess;
|
|
15
|
+
#isMetaFileWithReloadsEnabled;
|
|
16
|
+
#isMetaFileWithReloadsDisabled;
|
|
17
|
+
get #colors() {
|
|
18
|
+
return this.#logger.getColors();
|
|
19
|
+
}
|
|
20
|
+
constructor(cwd, options) {
|
|
21
|
+
this.#cwd = cwd;
|
|
22
|
+
this.#options = options;
|
|
23
|
+
this.#isMetaFileWithReloadsEnabled = picomatch((this.#options.metaFiles || [])
|
|
24
|
+
.filter(({ reloadServer }) => reloadServer === true)
|
|
25
|
+
.map(({ pattern }) => pattern));
|
|
26
|
+
this.#isMetaFileWithReloadsDisabled = picomatch((this.#options.metaFiles || [])
|
|
27
|
+
.filter(({ reloadServer }) => reloadServer !== true)
|
|
28
|
+
.map(({ pattern }) => pattern));
|
|
29
|
+
}
|
|
30
|
+
#isDotEnvFile(filePath) {
|
|
31
|
+
if (filePath === '.env') {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return filePath.includes('.env.');
|
|
35
|
+
}
|
|
36
|
+
#isRcFile(filePath) {
|
|
37
|
+
return filePath === '.adonisrc.json';
|
|
38
|
+
}
|
|
39
|
+
#isAdonisJSReadyMessage(message) {
|
|
40
|
+
return (message !== null &&
|
|
41
|
+
typeof message === 'object' &&
|
|
42
|
+
'isAdonisJS' in message &&
|
|
43
|
+
'environment' in message &&
|
|
44
|
+
message.environment === 'web');
|
|
45
|
+
}
|
|
46
|
+
#clearScreen() {
|
|
47
|
+
if (this.#options.clearScreen) {
|
|
48
|
+
process.stdout.write('\u001Bc');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async #getPort() {
|
|
52
|
+
if (process.env.PORT) {
|
|
53
|
+
return getPort({ port: Number(process.env.PORT) });
|
|
54
|
+
}
|
|
55
|
+
const files = await new EnvLoader(this.#cwd).load();
|
|
56
|
+
for (let file of files) {
|
|
57
|
+
const envVariables = new EnvParser(file.contents).parse();
|
|
58
|
+
if (envVariables.PORT) {
|
|
59
|
+
return getPort({ port: Number(envVariables.PORT) });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return getPort({ port: 3333 });
|
|
63
|
+
}
|
|
64
|
+
#startHTTPServer(port) {
|
|
65
|
+
this.#httpServerProcess = run(this.#cwd, {
|
|
66
|
+
script: this.#scriptFile,
|
|
67
|
+
env: { PORT: port, ...this.#options.env },
|
|
68
|
+
nodeArgs: this.#options.nodeArgs,
|
|
69
|
+
scriptArgs: this.#options.scriptArgs,
|
|
70
|
+
});
|
|
71
|
+
this.#httpServerProcess.on('message', (message) => {
|
|
72
|
+
if (this.#isAdonisJSReadyMessage(message)) {
|
|
73
|
+
ui.sticker()
|
|
74
|
+
.useColors(this.#colors)
|
|
75
|
+
.useRenderer(this.#logger.getRenderer())
|
|
76
|
+
.add(`Server address: ${this.#colors.cyan(`http://${message.host}:${message.port}`)}`)
|
|
77
|
+
.add(`File system watcher: ${this.#colors.cyan(`${this.#isWatching ? 'enabled' : 'disabled'}`)}`)
|
|
78
|
+
.render();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
this.#httpServerProcess.on('error', (error) => {
|
|
82
|
+
this.#logger.warning('unable to connect to underlying HTTP server process');
|
|
83
|
+
this.#logger.fatal(error);
|
|
84
|
+
});
|
|
85
|
+
this.#httpServerProcess.on('close', (exitCode) => {
|
|
86
|
+
this.#logger.warning(`underlying HTTP server closed with status code "${exitCode}"`);
|
|
87
|
+
this.#logger.info('watching file system and waiting for application to recover');
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
#restart(port) {
|
|
91
|
+
if (this.#httpServerProcess) {
|
|
92
|
+
this.#httpServerProcess.removeAllListeners();
|
|
93
|
+
this.#httpServerProcess.kill('SIGKILL');
|
|
94
|
+
}
|
|
95
|
+
this.#startHTTPServer(port);
|
|
96
|
+
}
|
|
97
|
+
setLogger(logger) {
|
|
98
|
+
this.#logger = logger;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
async start() {
|
|
102
|
+
this.#clearScreen();
|
|
103
|
+
this.#logger.info('starting HTTP server...');
|
|
104
|
+
this.#startHTTPServer(String(await this.#getPort()));
|
|
105
|
+
}
|
|
106
|
+
async startAndWatch(ts, options) {
|
|
107
|
+
const port = String(await this.#getPort());
|
|
108
|
+
this.#isWatching = true;
|
|
109
|
+
this.#clearScreen();
|
|
110
|
+
this.#logger.info('starting HTTP server...');
|
|
111
|
+
this.#startHTTPServer(port);
|
|
112
|
+
const output = watch(this.#cwd, ts, options || {});
|
|
113
|
+
if (!output) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
output.watcher.on('watcher:ready', () => {
|
|
117
|
+
this.#logger.info('watching file system for changes...');
|
|
118
|
+
});
|
|
119
|
+
output.watcher.on('source:add', ({ relativePath }) => {
|
|
120
|
+
this.#clearScreen();
|
|
121
|
+
this.#logger.log(`${this.#colors.green('add')} ${relativePath}`);
|
|
122
|
+
this.#restart(port);
|
|
123
|
+
});
|
|
124
|
+
output.watcher.on('source:change', ({ relativePath }) => {
|
|
125
|
+
this.#clearScreen();
|
|
126
|
+
this.#logger.log(`${this.#colors.green('update')} ${relativePath}`);
|
|
127
|
+
this.#restart(port);
|
|
128
|
+
});
|
|
129
|
+
output.watcher.on('source:unlink', ({ relativePath }) => {
|
|
130
|
+
this.#clearScreen();
|
|
131
|
+
this.#logger.log(`${this.#colors.green('delete')} ${relativePath}`);
|
|
132
|
+
this.#restart(port);
|
|
133
|
+
});
|
|
134
|
+
output.watcher.on('add', ({ relativePath }) => {
|
|
135
|
+
if (this.#isDotEnvFile(relativePath) || this.#isRcFile(relativePath)) {
|
|
136
|
+
this.#clearScreen();
|
|
137
|
+
this.#logger.log(`${this.#colors.green('add')} ${relativePath}`);
|
|
138
|
+
this.#restart(port);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (this.#isMetaFileWithReloadsEnabled(relativePath)) {
|
|
142
|
+
this.#clearScreen();
|
|
143
|
+
this.#logger.log(`${this.#colors.green('add')} ${relativePath}`);
|
|
144
|
+
this.#restart(port);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (this.#isMetaFileWithReloadsDisabled(relativePath)) {
|
|
148
|
+
this.#clearScreen();
|
|
149
|
+
this.#logger.log(`${this.#colors.green('add')} ${relativePath}`);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
output.watcher.on('change', ({ relativePath }) => {
|
|
153
|
+
if (this.#isDotEnvFile(relativePath) || this.#isRcFile(relativePath)) {
|
|
154
|
+
this.#clearScreen();
|
|
155
|
+
this.#logger.log(`${this.#colors.green('update')} ${relativePath}`);
|
|
156
|
+
this.#restart(port);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (this.#isMetaFileWithReloadsEnabled(relativePath)) {
|
|
160
|
+
this.#clearScreen();
|
|
161
|
+
this.#logger.log(`${this.#colors.green('update')} ${relativePath}`);
|
|
162
|
+
this.#restart(port);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (this.#isMetaFileWithReloadsDisabled(relativePath)) {
|
|
166
|
+
this.#clearScreen();
|
|
167
|
+
this.#logger.log(`${this.#colors.green('update')} ${relativePath}`);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
output.watcher.on('unlink', ({ relativePath }) => {
|
|
171
|
+
if (this.#isDotEnvFile(relativePath) || this.#isRcFile(relativePath)) {
|
|
172
|
+
this.#clearScreen();
|
|
173
|
+
this.#logger.log(`${this.#colors.green('delete')} ${relativePath}`);
|
|
174
|
+
this.#restart(port);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (this.#isMetaFileWithReloadsEnabled(relativePath)) {
|
|
178
|
+
this.#clearScreen();
|
|
179
|
+
this.#logger.log(`${this.#colors.green('delete')} ${relativePath}`);
|
|
180
|
+
this.#restart(port);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (this.#isMetaFileWithReloadsDisabled(relativePath)) {
|
|
184
|
+
this.#clearScreen();
|
|
185
|
+
this.#logger.log(`${this.#colors.green('delete')} ${relativePath}`);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
package/build/src/run.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execaNode } from 'execa';
|
|
2
|
+
const DEFAULT_NODE_ARGS = [
|
|
3
|
+
'--loader=ts-node/esm',
|
|
4
|
+
'--no-warnings',
|
|
5
|
+
'--experimental-import-meta-resolve',
|
|
6
|
+
];
|
|
7
|
+
export function run(cwd, options) {
|
|
8
|
+
const childProces = execaNode(options.script, options.scriptArgs, {
|
|
9
|
+
nodeOptions: DEFAULT_NODE_ARGS.concat(options.nodeArgs),
|
|
10
|
+
preferLocal: true,
|
|
11
|
+
windowsHide: false,
|
|
12
|
+
localDir: cwd,
|
|
13
|
+
cwd,
|
|
14
|
+
buffer: false,
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
env: options.env,
|
|
17
|
+
});
|
|
18
|
+
return childProces;
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export type RunOptions = {
|
|
3
|
+
script: string;
|
|
4
|
+
scriptArgs: string[];
|
|
5
|
+
nodeArgs: string[];
|
|
6
|
+
env?: NodeJS.ProcessEnv;
|
|
7
|
+
};
|
|
8
|
+
export type WatchOptions = {
|
|
9
|
+
poll?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type DevServerOptions = {
|
|
12
|
+
scriptArgs: string[];
|
|
13
|
+
nodeArgs: string[];
|
|
14
|
+
clearScreen?: boolean;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
metaFiles?: {
|
|
17
|
+
pattern: string;
|
|
18
|
+
reloadServer: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export type BundlerOptions = {
|
|
22
|
+
metaFiles?: {
|
|
23
|
+
pattern: string;
|
|
24
|
+
reloadServer: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { Watcher } from '@poppinss/chokidar-ts';
|
|
4
|
+
import type { WatchOptions } from './types.js';
|
|
5
|
+
export declare function watch(cwd: string | URL, ts: typeof tsStatic, options: WatchOptions): {
|
|
6
|
+
watcher: Watcher;
|
|
7
|
+
chokidar: import("chokidar").FSWatcher;
|
|
8
|
+
} | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { ConfigParser, Watcher } from '@poppinss/chokidar-ts';
|
|
3
|
+
export function watch(cwd, ts, options) {
|
|
4
|
+
const { config, error } = new ConfigParser(cwd, 'tsconfig.json', ts).parse();
|
|
5
|
+
if (error) {
|
|
6
|
+
const compilerHost = ts.createCompilerHost({});
|
|
7
|
+
console.log(ts.formatDiagnosticsWithColorAndContext([error], compilerHost));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (config.errors.length) {
|
|
11
|
+
const compilerHost = ts.createCompilerHost({});
|
|
12
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(config.errors, compilerHost));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const watcher = new Watcher(typeof cwd === 'string' ? cwd : fileURLToPath(cwd), config);
|
|
16
|
+
const chokidar = watcher.watch(['.'], { usePolling: options.poll });
|
|
17
|
+
return { watcher, chokidar };
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,135 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "build/
|
|
3
|
+
"version": "6.0.0-0",
|
|
4
|
+
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"files": [
|
|
7
|
-
"build/commands",
|
|
8
|
-
"build/config",
|
|
9
|
-
"build/templates",
|
|
10
8
|
"build/src",
|
|
11
|
-
"build/
|
|
12
|
-
"build/
|
|
13
|
-
"build/ace-manifest.json"
|
|
9
|
+
"build/index.d.ts",
|
|
10
|
+
"build/index.js"
|
|
14
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./build/index.js",
|
|
14
|
+
"./types": "./build/src/types.js"
|
|
15
|
+
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"mrm": "mrm --preset=@adonisjs/mrm-preset",
|
|
17
17
|
"pretest": "npm run lint",
|
|
18
|
-
"test": "cross-env
|
|
18
|
+
"test": "cross-env NODE_DEBUG=adonisjs:assembler c8 npm run vscode:test",
|
|
19
19
|
"lint": "eslint . --ext=.ts",
|
|
20
20
|
"clean": "del-cli build",
|
|
21
21
|
"compile": "npm run lint && npm run clean && tsc",
|
|
22
|
-
"build": "npm run compile
|
|
23
|
-
"
|
|
24
|
-
"release": "np --message=\"chore(release): %s\"",
|
|
22
|
+
"build": "npm run compile",
|
|
23
|
+
"release": "np",
|
|
25
24
|
"version": "npm run build",
|
|
26
|
-
"sync-labels": "github-label-sync --labels
|
|
25
|
+
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/assembler",
|
|
27
26
|
"format": "prettier --write .",
|
|
28
|
-
"prepublishOnly": "npm run build"
|
|
29
|
-
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|
|
27
|
+
"prepublishOnly": "npm run build",
|
|
28
|
+
"vscode:test": "node --loader=ts-node/esm bin/test.ts"
|
|
33
29
|
},
|
|
34
30
|
"keywords": [
|
|
35
31
|
"adonisjs",
|
|
36
|
-
"boot",
|
|
37
32
|
"build",
|
|
38
33
|
"ts"
|
|
39
34
|
],
|
|
40
35
|
"author": "virk,adonisjs",
|
|
41
36
|
"license": "MIT",
|
|
42
|
-
"bugs": {
|
|
43
|
-
"url": "https://github.com/adonisjs/assembler/issues"
|
|
44
|
-
},
|
|
45
|
-
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
46
37
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@japa/
|
|
51
|
-
"@japa/run-failed-tests": "^1.1.
|
|
52
|
-
"@japa/runner": "^2.
|
|
53
|
-
"@japa/spec-reporter": "^1.3.
|
|
38
|
+
"@commitlint/cli": "^17.4.4",
|
|
39
|
+
"@commitlint/config-conventional": "^17.4.4",
|
|
40
|
+
"@japa/assert": "^1.4.1",
|
|
41
|
+
"@japa/file-system": "^1.0.1",
|
|
42
|
+
"@japa/run-failed-tests": "^1.1.1",
|
|
43
|
+
"@japa/runner": "^2.5.1",
|
|
44
|
+
"@japa/spec-reporter": "^1.3.3",
|
|
45
|
+
"@poppinss/cliui": "^6.1.1-0",
|
|
54
46
|
"@poppinss/dev-utils": "^2.0.3",
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
47
|
+
"@swc/core": "^1.3.36",
|
|
48
|
+
"@types/node": "^18.14.1",
|
|
49
|
+
"c8": "^7.13.0",
|
|
57
50
|
"copyfiles": "^2.4.1",
|
|
58
51
|
"cross-env": "^7.0.3",
|
|
59
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
60
52
|
"del-cli": "^5.0.0",
|
|
61
|
-
"eslint": "^8.
|
|
62
|
-
"eslint-config-prettier": "^8.
|
|
63
|
-
"eslint-plugin-adonis": "^
|
|
53
|
+
"eslint": "^8.34.0",
|
|
54
|
+
"eslint-config-prettier": "^8.6.0",
|
|
55
|
+
"eslint-plugin-adonis": "^3.0.3",
|
|
64
56
|
"eslint-plugin-prettier": "^4.2.1",
|
|
65
57
|
"github-label-sync": "^2.2.0",
|
|
66
|
-
"husky": "^8.0.
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"prettier": "^2.
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
"nyc": {
|
|
73
|
-
"exclude": [
|
|
74
|
-
"test"
|
|
75
|
-
],
|
|
76
|
-
"extension": [
|
|
77
|
-
".ts"
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
"husky": {
|
|
81
|
-
"hooks": {
|
|
82
|
-
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"config": {
|
|
86
|
-
"commitizen": {
|
|
87
|
-
"path": "cz-conventional-changelog"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"np": {
|
|
91
|
-
"contents": ".",
|
|
92
|
-
"anyBranch": false
|
|
58
|
+
"husky": "^8.0.3",
|
|
59
|
+
"np": "^7.6.3",
|
|
60
|
+
"p-event": "^5.0.1",
|
|
61
|
+
"prettier": "^2.8.4",
|
|
62
|
+
"ts-node": "^10.9.1",
|
|
63
|
+
"typescript": "^4.9.5"
|
|
93
64
|
},
|
|
94
65
|
"dependencies": {
|
|
95
|
-
"@adonisjs/
|
|
96
|
-
"@
|
|
97
|
-
"@
|
|
98
|
-
"@
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"cpy": "^8.1.2",
|
|
104
|
-
"emittery": "^0.13.1",
|
|
105
|
-
"execa": "^5.1.1",
|
|
106
|
-
"fs-extra": "^10.1.0",
|
|
107
|
-
"get-port": "^5.1.1",
|
|
108
|
-
"glob-parent": "^6.0.2",
|
|
109
|
-
"has-yarn": "^2.1.0",
|
|
66
|
+
"@adonisjs/env": "^4.2.0-0",
|
|
67
|
+
"@poppinss/chokidar-ts": "^4.0.0-0",
|
|
68
|
+
"@types/fs-extra": "^11.0.1",
|
|
69
|
+
"@types/picomatch": "^2.3.0",
|
|
70
|
+
"cpy": "^9.0.1",
|
|
71
|
+
"execa": "^7.0.0",
|
|
72
|
+
"fs-extra": "^11.1.0",
|
|
73
|
+
"get-port": "^6.1.2",
|
|
110
74
|
"picomatch": "^2.3.1",
|
|
111
|
-
"slash": "^
|
|
75
|
+
"slash": "^5.0.0"
|
|
112
76
|
},
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
|
|
116
|
-
"publishConfig": {
|
|
117
|
-
"access": "public",
|
|
118
|
-
"tag": "latest"
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|
|
119
80
|
},
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"license": "MIT",
|
|
123
|
-
"services": [
|
|
124
|
-
"github-actions"
|
|
125
|
-
],
|
|
126
|
-
"minNodeVersion": "14.15.4",
|
|
127
|
-
"probotApps": [
|
|
128
|
-
"stale",
|
|
129
|
-
"lock"
|
|
130
|
-
],
|
|
131
|
-
"runGhActionsOnWindows": true
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/adonisjs/assembler/issues"
|
|
132
83
|
},
|
|
84
|
+
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
133
85
|
"eslintConfig": {
|
|
134
86
|
"extends": [
|
|
135
87
|
"plugin:adonis/typescriptPackage",
|
|
@@ -159,5 +111,31 @@
|
|
|
159
111
|
"bracketSpacing": true,
|
|
160
112
|
"arrowParens": "always",
|
|
161
113
|
"printWidth": 100
|
|
114
|
+
},
|
|
115
|
+
"commitlint": {
|
|
116
|
+
"extends": [
|
|
117
|
+
"@commitlint/config-conventional"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"publishConfig": {
|
|
121
|
+
"access": "public",
|
|
122
|
+
"tag": "next"
|
|
123
|
+
},
|
|
124
|
+
"np": {
|
|
125
|
+
"message": "chore(release): %s",
|
|
126
|
+
"tag": "next",
|
|
127
|
+
"branch": "main",
|
|
128
|
+
"anyBranch": false
|
|
129
|
+
},
|
|
130
|
+
"c8": {
|
|
131
|
+
"reporter": [
|
|
132
|
+
"text",
|
|
133
|
+
"html"
|
|
134
|
+
],
|
|
135
|
+
"exclude": [
|
|
136
|
+
"tests/**",
|
|
137
|
+
"build/**",
|
|
138
|
+
"examples/**"
|
|
139
|
+
]
|
|
162
140
|
}
|
|
163
141
|
}
|