@adonisjs/assembler
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,2 +6,3 @@ import { Logger } from '@poppinss/fancy-logs'; | ||
private _logger; | ||
private _manifest; | ||
constructor(_buildRoot: string, _nodeArgs: string[], _logger?: Logger); | ||
@@ -8,0 +9,0 @@ private _isScriptFile; |
@@ -11,2 +11,3 @@ "use strict"; | ||
const RcFile_1 = require("../RcFile"); | ||
const Manifest_1 = require("../Manifest"); | ||
const HttpServer_1 = require("../HttpServer"); | ||
@@ -19,2 +20,3 @@ const paths_1 = require("../../config/paths"); | ||
this._logger = _logger; | ||
this._manifest = new Manifest_1.Manifest(this._buildRoot, this._logger); | ||
} | ||
@@ -46,16 +48,25 @@ _isScriptFile(filePath) { | ||
const metaData = rcFile.getMetaData(filePath); | ||
if (this._isScriptFile(filePath) || metaData.reload) { | ||
const isScriptFile = this._isScriptFile(filePath); | ||
if (isScriptFile || metaData.reload) { | ||
this._logger.create(filePath); | ||
httpServer.restart(); | ||
} | ||
if (isScriptFile && rcFile.isCommandsPath(filePath)) { | ||
this._manifest.generate(); | ||
} | ||
}); | ||
watcher.on('change', (filePath) => { | ||
const metaData = rcFile.getMetaData(filePath); | ||
if (this._isScriptFile(filePath) || metaData.reload) { | ||
const isScriptFile = this._isScriptFile(filePath); | ||
if (isScriptFile || metaData.reload) { | ||
this._logger.update(filePath); | ||
httpServer.restart(); | ||
} | ||
if (isScriptFile && rcFile.isCommandsPath(filePath)) { | ||
this._manifest.generate(); | ||
} | ||
}); | ||
watcher.on('unlink', (filePath) => { | ||
const metaData = rcFile.getMetaData(filePath); | ||
const isScriptFile = this._isScriptFile(filePath); | ||
if (metaData.rcFile) { | ||
@@ -66,6 +77,9 @@ this._logger.stop('cannot continue after deletion of .adonisrc.json file'); | ||
} | ||
if (this._isScriptFile(filePath) || metaData.reload) { | ||
if (isScriptFile || metaData.reload) { | ||
this._logger.delete(filePath); | ||
httpServer.restart(); | ||
} | ||
if (isScriptFile && rcFile.isCommandsPath(filePath)) { | ||
this._manifest.generate(); | ||
} | ||
}); | ||
@@ -72,0 +86,0 @@ watcher.on('ready', () => { |
@@ -5,2 +5,3 @@ import tsStatic from 'typescript'; | ||
import { RcFile } from '../RcFile'; | ||
import { Manifest } from '../Manifest'; | ||
import { HttpServer, DummyHttpServer } from '../HttpServer'; | ||
@@ -15,3 +16,4 @@ export declare class Compiler { | ||
rcFile: RcFile; | ||
private _getRelativePath; | ||
manifest: Manifest; | ||
private _getRelativeUnixPath; | ||
constructor(appRoot: string, _serveApp: boolean, _nodeArgs?: string[], _logger?: Logger); | ||
@@ -18,0 +20,0 @@ createHttpServer(outDir: string): void; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const mem_1 = __importDefault(require("mem")); | ||
const slash_1 = __importDefault(require("slash")); | ||
const cpy_1 = __importDefault(require("cpy")); | ||
@@ -16,2 +17,3 @@ const path_1 = require("path"); | ||
const RcFile_1 = require("../RcFile"); | ||
const Manifest_1 = require("../Manifest"); | ||
const Installer_1 = require("../Installer"); | ||
@@ -28,4 +30,5 @@ const HttpServer_1 = require("../HttpServer"); | ||
this.rcFile = new RcFile_1.RcFile(this.appRoot); | ||
this._getRelativePath = mem_1.default((absPath) => { | ||
return absPath.replace(new RegExp(`^${this.appRoot}${path_1.sep}`), ''); | ||
this.manifest = new Manifest_1.Manifest(this.appRoot, this._logger); | ||
this._getRelativeUnixPath = mem_1.default((absPath) => { | ||
return slash_1.default(path_1.relative(this.appRoot, absPath)); | ||
}); | ||
@@ -63,7 +66,7 @@ this.tsCompiler.use(() => { | ||
async cleanupBuildDirectory(outDir) { | ||
this._logger.info({ message: 'cleaning up build directory', suffix: this._getRelativePath(outDir) }); | ||
this._logger.info({ message: 'cleaning up build directory', suffix: this._getRelativeUnixPath(outDir) }); | ||
await fs_extra_1.remove(outDir); | ||
} | ||
async copyAdonisRcFile(outDir) { | ||
this._logger.info({ message: `copy ${paths_1.RCFILE_NAME}`, suffix: this._getRelativePath(outDir) }); | ||
this._logger.info({ message: `copy ${paths_1.RCFILE_NAME}`, suffix: this._getRelativeUnixPath(outDir) }); | ||
await fs_extra_1.outputJSON(path_1.join(outDir, paths_1.RCFILE_NAME), Object.assign({}, this.rcFile.raw, { typescript: false })); | ||
@@ -73,3 +76,3 @@ } | ||
const metaFiles = this.rcFile.getMetaFilesGlob().concat(extraFiles || []); | ||
this._logger.info({ message: `copy ${metaFiles.join(',')}`, suffix: this._getRelativePath(outDir) }); | ||
this._logger.info({ message: `copy ${metaFiles.join(',')}`, suffix: this._getRelativeUnixPath(outDir) }); | ||
await this.copyFiles(metaFiles, outDir); | ||
@@ -104,2 +107,3 @@ } | ||
this.buildTypescriptSource(config); | ||
await this.manifest.generate(); | ||
if (this._serveApp) { | ||
@@ -125,2 +129,3 @@ this.createHttpServer(config.options.outDir); | ||
await new Installer_1.Installer(config.options.outDir, client).install(); | ||
await this.manifest.generate(); | ||
if (this._serveApp) { | ||
@@ -127,0 +132,0 @@ this.createHttpServer(config.options.outDir); |
@@ -9,2 +9,3 @@ import { Application } from '@adonisjs/application/build/standalone'; | ||
isRestartServerFile: (filePath: string) => boolean; | ||
isCommandsPath: (filePath: string) => boolean; | ||
constructor(_appRoot: string); | ||
@@ -14,2 +15,3 @@ isRcFile(filePath: string): boolean; | ||
getRestartServerFilesGlob(): string[]; | ||
commandsGlob(): string[]; | ||
getMetaData(filePath: string): { | ||
@@ -16,0 +18,0 @@ reload: boolean; |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const slash_1 = __importDefault(require("slash")); | ||
const picomatch_1 = __importDefault(require("picomatch")); | ||
const path_1 = require("path"); | ||
const fold_1 = require("@adonisjs/fold"); | ||
@@ -20,2 +22,3 @@ const utils_1 = require("@poppinss/utils"); | ||
this.isRestartServerFile = picomatch_1.default(this.getRestartServerFilesGlob()); | ||
this.isCommandsPath = picomatch_1.default(this.commandsGlob()); | ||
} | ||
@@ -29,4 +32,5 @@ isRcFile(filePath) { | ||
.metaFiles | ||
.filter(({ pattern }) => pattern !== paths_1.RCFILE_NAME) | ||
.map(({ pattern }) => pattern); | ||
.filter(({ pattern }) => ![paths_1.RCFILE_NAME, paths_1.ACE_FILE_NAME].includes(pattern)) | ||
.map(({ pattern }) => pattern) | ||
.concat([paths_1.ACE_FILE_NAME]); | ||
} | ||
@@ -36,6 +40,17 @@ getRestartServerFilesGlob() { | ||
.filter(({ reloadServer, pattern }) => { | ||
return reloadServer === true && pattern !== paths_1.RCFILE_NAME; | ||
return reloadServer === true && ![paths_1.RCFILE_NAME, paths_1.ACE_FILE_NAME].includes(pattern); | ||
}) | ||
.map(({ pattern }) => pattern); | ||
} | ||
commandsGlob() { | ||
const commands = this.application.rcFile.commands | ||
.reduce((result, commandPath) => { | ||
if (/^(.){1,2}\//.test(commandPath)) { | ||
commandPath = slash_1.default(path_1.relative(this._appRoot, path_1.join(this._appRoot, commandPath))); | ||
result = result.concat([`${commandPath}.*`, `${commandPath}/**/*`]); | ||
} | ||
return result; | ||
}, []); | ||
return commands; | ||
} | ||
getMetaData(filePath) { | ||
@@ -42,0 +57,0 @@ if (this.isRcFile(filePath)) { |
@@ -26,2 +26,3 @@ "use strict"; | ||
this.compiler.buildTypescriptSource(config); | ||
this.compiler.manifest.generate(); | ||
this.compiler.createHttpServer(config.options.outDir); | ||
@@ -40,8 +41,12 @@ this.compiler.httpServer.on('exit', ({ code }) => { | ||
this._logger.compile(path); | ||
if (!skipped) { | ||
this.compiler.httpServer.restart(); | ||
} | ||
if (diagnostics.length) { | ||
this.compiler.renderDiagnostics(diagnostics, watcher.host); | ||
} | ||
if (skipped) { | ||
return; | ||
} | ||
this.compiler.httpServer.restart(); | ||
if (this.compiler.rcFile.isCommandsPath(path)) { | ||
this.compiler.manifest.generate(); | ||
} | ||
}); | ||
@@ -48,0 +53,0 @@ watcher.on('source:unlink', async (filePath) => { |
{ | ||
"name": "@adonisjs/assembler", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Core commands to compiler and build AdonisJs project", | ||
"main": "build/index.js", | ||
"files": [ | ||
"build/commands", | ||
"build/config", | ||
"build/src", | ||
@@ -41,7 +43,7 @@ "build/ace-manifest.json", | ||
"devDependencies": { | ||
"@adonisjs/ace": "^6.5.0", | ||
"@adonisjs/ace": "^6.6.1", | ||
"@adonisjs/fold": "^6.2.3", | ||
"@adonisjs/mrm-preset": "^2.1.0", | ||
"@poppinss/dev-utils": "^1.0.1", | ||
"@types/node": "^12.12.8", | ||
"@types/node": "^12.12.11", | ||
"commitizen": "^4.0.3", | ||
@@ -90,3 +92,3 @@ "cz-conventional-changelog": "^3.0.2", | ||
"@poppinss/chokidar-ts": "^2.0.0", | ||
"@poppinss/fancy-logs": "^1.3.0", | ||
"@poppinss/fancy-logs": "^1.3.1", | ||
"@poppinss/utils": "^2.1.0", | ||
@@ -99,4 +101,5 @@ "chokidar": "^3.3.0", | ||
"mem": "^6.0.0", | ||
"picomatch": "^2.1.1" | ||
"picomatch": "^2.1.1", | ||
"slash": "^3.0.0" | ||
} | ||
} |
37989
28
797
14
+ Addedslash@^3.0.0
Updated@poppinss/fancy-logs@^1.3.1