@adonisjs/assembler 6.1.3-3 → 6.1.3-30
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/README.md +3 -6
- package/build/index.d.ts +1 -0
- package/build/index.js +918 -2
- package/build/index.js.map +1 -0
- package/build/src/assets_dev_server.d.ts +32 -0
- package/build/src/bundler.d.ts +12 -1
- package/build/src/code_transformer/main.d.ts +43 -0
- package/build/src/code_transformer/main.js +429 -0
- package/build/src/code_transformer/main.js.map +1 -0
- package/build/src/code_transformer/rc_file_transformer.d.ts +43 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/dev_server.d.ts +32 -0
- package/build/src/helpers.d.ts +46 -0
- package/build/src/test_runner.d.ts +47 -0
- package/build/src/types.d.ts +102 -0
- package/package.json +75 -72
- package/build/src/bundler.js +0 -152
- package/build/src/dev_server.js +0 -286
- package/build/src/parse_config.d.ts +0 -3
- package/build/src/parse_config.js +0 -15
- package/build/src/run.d.ts +0 -4
- package/build/src/run.js +0 -37
- package/build/src/types.js +0 -1
- package/build/src/watch.d.ts +0 -8
- package/build/src/watch.js +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/code_transformer/main.ts","../../../src/code_transformer/rc_file_transformer.ts"],"sourcesContent":["/*\n * @adonisjs/assembler\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { installPackage, detectPackageManager } from '@antfu/install-pkg'\nimport {\n Node,\n Project,\n QuoteKind,\n SourceFile,\n SyntaxKind,\n CodeBlockWriter,\n FormatCodeSettings,\n} from 'ts-morph'\n\nimport { RcFileTransformer } from './rc_file_transformer.js'\nimport type { AddMiddlewareEntry, EnvValidationDefinition } from '../types.js'\n\n/**\n * This class is responsible for updating\n */\nexport class CodeTransformer {\n /**\n * Exporting utilities to install package and detect\n * the package manager\n */\n installPackage = installPackage\n detectPackageManager = detectPackageManager\n\n /**\n * Directory of the adonisjs project\n */\n #cwd: URL\n\n /**\n * The TsMorph project\n */\n #project: Project\n\n /**\n * Settings to use when persisting files\n */\n #editorSettings: FormatCodeSettings = {\n indentSize: 2,\n convertTabsToSpaces: true,\n trimTrailingWhitespace: true,\n // @ts-expect-error SemicolonPreference doesn't seem to be re-exported from ts-morph\n semicolons: 'remove',\n }\n\n constructor(cwd: URL) {\n this.#cwd = cwd\n this.#project = new Project({\n tsConfigFilePath: join(fileURLToPath(this.#cwd), 'tsconfig.json'),\n manipulationSettings: { quoteKind: QuoteKind.Single },\n })\n }\n\n /**\n * Add a new middleware to the middleware array of the\n * given file\n */\n #addToMiddlewareArray(file: SourceFile, target: string, middlewareEntry: AddMiddlewareEntry) {\n const callExpressions = file\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((statement) => statement.getExpression().getText() === target)\n\n if (!callExpressions.length) {\n throw new Error(`Cannot find ${target} statement in the file.`)\n }\n\n const arrayLiteralExpression = callExpressions[0].getArguments()[0]\n if (!arrayLiteralExpression || !Node.isArrayLiteralExpression(arrayLiteralExpression)) {\n throw new Error(`Cannot find middleware array in ${target} statement.`)\n }\n\n const middleware = `() => import('${middlewareEntry.path}')`\n\n /**\n * Delete the existing middleware if it exists\n */\n const existingMiddlewareIndex = arrayLiteralExpression\n .getElements()\n .findIndex((element) => element.getText() === middleware)\n\n if (existingMiddlewareIndex === -1) {\n /**\n * Add the middleware to the top or bottom of the array\n */\n if (middlewareEntry.position === 'before') {\n arrayLiteralExpression.insertElement(0, middleware)\n } else {\n arrayLiteralExpression.addElement(middleware)\n }\n }\n }\n\n /**\n * Add a new middleware to the named middleware of the given file\n */\n #addToNamedMiddleware(file: SourceFile, middlewareEntry: AddMiddlewareEntry) {\n if (!middlewareEntry.name) {\n throw new Error('Named middleware requires a name.')\n }\n\n const callArguments = file\n .getVariableDeclarationOrThrow('middleware')\n .getInitializerIfKindOrThrow(SyntaxKind.CallExpression)\n .getArguments()\n\n if (callArguments.length === 0) {\n throw new Error('Named middleware call has no arguments.')\n }\n\n const namedMiddlewareObject = callArguments[0]\n if (!Node.isObjectLiteralExpression(namedMiddlewareObject)) {\n throw new Error('The argument of the named middleware call is not an object literal.')\n }\n\n /**\n * Check if property is already defined. If so, remove it\n */\n const existingProperty = namedMiddlewareObject.getProperty(middlewareEntry.name)\n if (!existingProperty) {\n /**\n * Add the named middleware\n */\n const middleware = `${middlewareEntry.name}: () => import('${middlewareEntry.path}')`\n namedMiddlewareObject!.insertProperty(0, middleware)\n }\n }\n\n /**\n * Write a leading comment\n */\n #addLeadingComment(writer: CodeBlockWriter, comment?: string) {\n if (!comment) {\n return writer.blankLine()\n }\n\n return writer\n .blankLine()\n .writeLine('/*')\n .writeLine(`|----------------------------------------------------------`)\n .writeLine(`| ${comment}`)\n .writeLine(`|----------------------------------------------------------`)\n .writeLine(`*/`)\n }\n\n /**\n * Add new env variable validation in the\n * `env.ts` file\n */\n async defineEnvValidations(definition: EnvValidationDefinition) {\n /**\n * Get the `start/env.ts` source file\n */\n const kernelUrl = fileURLToPath(new URL('./start/env.ts', this.#cwd))\n const file = this.#project.getSourceFileOrThrow(kernelUrl)\n\n /**\n * Get the `Env.create` call expression\n */\n const callExpressions = file\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((statement) => statement.getExpression().getText() === 'Env.create')\n\n if (!callExpressions.length) {\n throw new Error(`Cannot find Env.create statement in the file.`)\n }\n\n const objectLiteralExpression = callExpressions[0].getArguments()[1]\n if (!Node.isObjectLiteralExpression(objectLiteralExpression)) {\n throw new Error(`The second argument of Env.create is not an object literal.`)\n }\n\n let shouldAddComment = true\n\n /**\n * Add each variable validation\n */\n for (const [variable, validation] of Object.entries(definition.variables)) {\n /**\n * Check if the variable is already defined. If so, remove it\n */\n const existingProperty = objectLiteralExpression.getProperty(variable)\n\n /**\n * Do not add leading comment if one or more properties\n * already exists\n */\n if (existingProperty) {\n shouldAddComment = false\n }\n\n /**\n * Add property only when the property does not exist\n */\n if (!existingProperty) {\n objectLiteralExpression.addPropertyAssignment({\n name: variable,\n initializer: validation,\n leadingTrivia: (writer) => {\n if (!shouldAddComment) {\n return\n }\n\n shouldAddComment = false\n return this.#addLeadingComment(writer, definition.leadingComment)\n },\n })\n }\n }\n\n file.formatText(this.#editorSettings)\n await file.save()\n }\n\n /**\n * Define new middlewares inside the `start/kernel.ts`\n * file\n *\n * This function is highly based on some assumptions\n * and will not work if you significantly tweaked\n * your `start/kernel.ts` file.\n */\n async addMiddlewareToStack(\n stack: 'server' | 'router' | 'named',\n middleware: AddMiddlewareEntry[]\n ) {\n /**\n * Get the `start/kernel.ts` source file\n */\n const kernelUrl = fileURLToPath(new URL('./start/kernel.ts', this.#cwd))\n const file = this.#project.getSourceFileOrThrow(kernelUrl)\n\n /**\n * Process each middleware entry\n */\n for (const middlewareEntry of middleware) {\n if (stack === 'named') {\n this.#addToNamedMiddleware(file, middlewareEntry)\n } else {\n this.#addToMiddlewareArray(file!, `${stack}.use`, middlewareEntry)\n }\n }\n\n file.formatText(this.#editorSettings)\n await file.save()\n }\n\n /**\n * Update the `adonisrc.ts` file\n */\n async updateRcFile(callback: (transformer: RcFileTransformer) => void) {\n const rcFileTransformer = new RcFileTransformer(this.#cwd, this.#project)\n callback(rcFileTransformer)\n await rcFileTransformer.save()\n }\n\n /**\n * Add a new Japa plugin in the `tests/bootstrap.ts` file\n */\n async addJapaPlugin(\n pluginCall: string,\n importDeclaration: { isNamed: boolean; module: string; identifier: string }\n ) {\n /**\n * Get the `tests/bootstrap.ts` source file\n */\n const testBootstrapUrl = fileURLToPath(new URL('./tests/bootstrap.ts', this.#cwd))\n const file = this.#project.getSourceFileOrThrow(testBootstrapUrl)\n\n /**\n * Add the import declaration\n */\n file.addImportDeclaration({\n ...(importDeclaration.isNamed\n ? { namedImports: [importDeclaration.identifier] }\n : { defaultImport: importDeclaration.identifier }),\n moduleSpecifier: importDeclaration.module,\n })\n\n /**\n * Insert the plugin call in the `plugins` array\n */\n const pluginsArray = file\n .getVariableDeclaration('plugins')\n ?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression)\n\n if (pluginsArray) pluginsArray.addElement(pluginCall)\n\n file.formatText(this.#editorSettings)\n await file.save()\n }\n}\n","import { fileURLToPath } from 'node:url'\nimport type { AppEnvironments } from '@adonisjs/application/types'\nimport {\n Node,\n Project,\n SourceFile,\n SyntaxKind,\n CallExpression,\n PropertyAssignment,\n ArrayLiteralExpression,\n} from 'ts-morph'\n\n/**\n * RcFileTransformer is used to transform the `adonisrc.ts` file\n * for adding new commands, providers, meta files etc\n */\nexport class RcFileTransformer {\n #cwd: URL\n #project: Project\n\n /**\n * Settings to use when persisting files\n */\n #editorSettings = {\n indentSize: 2,\n convertTabsToSpaces: true,\n trimTrailingWhitespace: true,\n }\n\n constructor(cwd: URL, project: Project) {\n this.#cwd = cwd\n this.#project = project\n }\n\n /**\n * Get the `adonisrc.ts` source file\n */\n #getRcFileOrThrow() {\n const kernelUrl = fileURLToPath(new URL('./adonisrc.ts', this.#cwd))\n return this.#project.getSourceFileOrThrow(kernelUrl)\n }\n\n /**\n * Check if environments array has a subset of available environments\n */\n #isInSpecificEnvironment(environments?: AppEnvironments[]): boolean {\n if (!environments) return false\n\n return !!(['web', 'console', 'test', 'repl'] as const).find(\n (env) => !environments.includes(env)\n )\n }\n\n /**\n * Locate the `defineConfig` call inside the `adonisrc.ts` file\n */\n #locateDefineConfigCallOrThrow(file: SourceFile) {\n const call = file\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((statement) => statement.getExpression().getText() === 'defineConfig')\n\n if (!call) {\n throw new Error('Could not locate the defineConfig call.')\n }\n\n return call\n }\n\n /**\n * Return the ObjectLiteralExpression of the defineConfig call\n */\n #getDefineConfigObjectOrThrow(defineConfigCall: CallExpression) {\n const configObject = defineConfigCall\n .getArguments()[0]\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n return configObject\n }\n\n /**\n * Check if the defineConfig() call has the property assignment\n * inside it or not. If not, it will create one and return it.\n */\n #getPropertyAssignmentInDefineConfigCall(propertyName: string, initializer: string) {\n const file = this.#getRcFileOrThrow()\n const defineConfigCall = this.#locateDefineConfigCallOrThrow(file)\n const configObject = this.#getDefineConfigObjectOrThrow(defineConfigCall)\n\n let property = configObject.getProperty(propertyName)\n\n if (!property) {\n configObject.addPropertyAssignment({ name: propertyName, initializer })\n property = configObject.getProperty(propertyName)\n }\n\n return property as PropertyAssignment\n }\n\n /**\n * Extract list of imported modules from an ArrayLiteralExpression\n *\n * It assumes that the array can have two types of elements:\n *\n * - Simple lazy imported modules: [() => import('path/to/file')]\n * - Or an object entry: [{ file: () => import('path/to/file'), environment: ['web', 'console'] }]\n * where the `file` property is a lazy imported module.\n */\n #extractModulesFromArray(array: ArrayLiteralExpression) {\n const modules = array.getElements().map((element) => {\n /**\n * Simple lazy imported module\n */\n if (Node.isArrowFunction(element)) {\n const importExp = element.getFirstDescendantByKindOrThrow(SyntaxKind.CallExpression)\n const literal = importExp.getFirstDescendantByKindOrThrow(SyntaxKind.StringLiteral)\n return literal.getLiteralValue()\n }\n\n /**\n * Object entry\n */\n if (Node.isObjectLiteralExpression(element)) {\n const fileProp = element.getPropertyOrThrow('file') as PropertyAssignment\n const arrowFn = fileProp.getFirstDescendantByKindOrThrow(SyntaxKind.ArrowFunction)\n const importExp = arrowFn.getFirstDescendantByKindOrThrow(SyntaxKind.CallExpression)\n const literal = importExp.getFirstDescendantByKindOrThrow(SyntaxKind.StringLiteral)\n return literal.getLiteralValue()\n }\n })\n\n return modules.filter(Boolean) as string[]\n }\n\n /**\n * Extract a specific property from an ArrayLiteralExpression\n * that contains object entries.\n *\n * This function is mainly used for extractring the `pattern` property\n * when adding a new meta files entry, or the `name` property when\n * adding a new test suite.\n */\n #extractPropertyFromArray(array: ArrayLiteralExpression, propertyName: string) {\n const property = array.getElements().map((el) => {\n if (!Node.isObjectLiteralExpression(el)) return\n\n const nameProp = el.getPropertyOrThrow(propertyName)\n if (!Node.isPropertyAssignment(nameProp)) return\n\n const name = nameProp.getInitializerIfKindOrThrow(SyntaxKind.StringLiteral)\n return name.getLiteralValue()\n })\n\n return property.filter(Boolean) as string[]\n }\n\n /**\n * Build a new module entry for the preloads and providers array\n * based upon the environments specified\n */\n #buildNewModuleEntry(modulePath: string, environments?: AppEnvironments[]) {\n if (!this.#isInSpecificEnvironment(environments)) {\n return `() => import('${modulePath}')`\n }\n\n return `{\n file: () => import('${modulePath}'),\n environment: [${environments?.map((env) => `'${env}'`).join(', ')}],\n }`\n }\n\n /**\n * Add a new command to the rcFile\n */\n addCommand(commandPath: string) {\n const commandsProperty = this.#getPropertyAssignmentInDefineConfigCall('commands', '[]')\n const commandsArray = commandsProperty.getInitializerIfKindOrThrow(\n SyntaxKind.ArrayLiteralExpression\n )\n\n const commandString = `() => import('${commandPath}')`\n\n /**\n * If the command already exists, do nothing\n */\n if (commandsArray.getElements().some((el) => el.getText() === commandString)) {\n return this\n }\n\n /**\n * Add the command to the array\n */\n commandsArray.addElement(commandString)\n return this\n }\n\n /**\n * Add a new preloaded file to the rcFile\n */\n addPreloadFile(modulePath: string, environments?: AppEnvironments[]) {\n const preloadsProperty = this.#getPropertyAssignmentInDefineConfigCall('preloads', '[]')\n const preloadsArray = preloadsProperty.getInitializerIfKindOrThrow(\n SyntaxKind.ArrayLiteralExpression\n )\n\n /**\n * Check for duplicates\n */\n const existingPreloadedFiles = this.#extractModulesFromArray(preloadsArray)\n const isDuplicate = existingPreloadedFiles.includes(modulePath)\n if (isDuplicate) {\n return this\n }\n\n /**\n * Add the preloaded file to the array\n */\n preloadsArray.addElement(this.#buildNewModuleEntry(modulePath, environments))\n return this\n }\n\n /**\n * Add a new provider to the rcFile\n */\n addProvider(providerPath: string, environments?: AppEnvironments[]) {\n const property = this.#getPropertyAssignmentInDefineConfigCall('providers', '[]')\n const providersArray = property.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n /**\n * Check for duplicates\n */\n const existingProviderPaths = this.#extractModulesFromArray(providersArray)\n const isDuplicate = existingProviderPaths.includes(providerPath)\n if (isDuplicate) {\n return this\n }\n\n /**\n * Add the provider to the array\n */\n providersArray.addElement(this.#buildNewModuleEntry(providerPath, environments))\n\n return this\n }\n\n /**\n * Add a new meta file to the rcFile\n */\n addMetaFile(globPattern: string, reloadServer = false) {\n const property = this.#getPropertyAssignmentInDefineConfigCall('metaFiles', '[]')\n const metaFilesArray = property.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n /**\n * Check for duplicates\n */\n const alreadyDefinedPatterns = this.#extractPropertyFromArray(metaFilesArray, 'pattern')\n if (alreadyDefinedPatterns.includes(globPattern)) {\n return this\n }\n\n /**\n * Add the meta file to the array\n */\n metaFilesArray.addElement(\n `{\n pattern: '${globPattern}',\n reloadServer: ${reloadServer},\n }`\n )\n\n return this\n }\n\n /**\n * Set directory name and path\n */\n setDirectory(key: string, value: string) {\n const property = this.#getPropertyAssignmentInDefineConfigCall('directories', '{}')\n const directories = property.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n directories.addPropertyAssignment({ name: key, initializer: `'${value}'` })\n\n return this\n }\n\n /**\n * Set command alias\n */\n setCommandAlias(alias: string, command: string) {\n const aliasProperty = this.#getPropertyAssignmentInDefineConfigCall('commandsAliases', '{}')\n const aliases = aliasProperty.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n aliases.addPropertyAssignment({ name: alias, initializer: `'${command}'` })\n\n return this\n }\n\n /**\n * Add a new test suite to the rcFile\n */\n addSuite(suiteName: string, files: string | string[], timeout?: number) {\n const testProperty = this.#getPropertyAssignmentInDefineConfigCall(\n 'tests',\n `{ suites: [], forceExit: true, timeout: 2000 }`\n )\n\n const property = testProperty\n .getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getPropertyOrThrow('suites') as PropertyAssignment\n\n const suitesArray = property.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n /**\n * Check for duplicates\n */\n const existingSuitesNames = this.#extractPropertyFromArray(suitesArray, 'name')\n if (existingSuitesNames.includes(suiteName)) {\n return this\n }\n\n /**\n * Add the suite to the array\n */\n const filesArray = Array.isArray(files) ? files : [files]\n suitesArray.addElement(\n `{\n name: '${suiteName}',\n files: [${filesArray.map((file) => `'${file}'`).join(', ')}],\n timeout: ${timeout ?? 2000},\n }`\n )\n\n return this\n }\n\n /**\n * Save the adonisrc.ts file\n */\n save() {\n const file = this.#getRcFileOrThrow()\n file.formatText(this.#editorSettings)\n return file.save()\n }\n}\n"],"mappings":";AASA,SAAS,YAAY;AACrB,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,gBAAgB,4BAA4B;AACrD;AAAA,EACE,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA;AAAA,EAEA,cAAAC;AAAA,OAGK;;;ACpBP,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EAGA;AAAA,OAIK;AAMA,IAAM,oBAAN,MAAwB;AAAA,EAC7B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AAAA,IAChB,YAAY;AAAA,IACZ,qBAAqB;AAAA,IACrB,wBAAwB;AAAA,EAC1B;AAAA,EAEA,YAAY,KAAU,SAAkB;AACtC,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB;AAClB,UAAM,YAAY,cAAc,IAAI,IAAI,iBAAiB,KAAK,IAAI,CAAC;AACnE,WAAO,KAAK,SAAS,qBAAqB,SAAS;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA,EAKA,yBAAyB,cAA2C;AAClE,QAAI,CAAC;AAAc,aAAO;AAE1B,WAAO,CAAC,CAAE,CAAC,OAAO,WAAW,QAAQ,MAAM,EAAY;AAAA,MACrD,CAAC,QAAQ,CAAC,aAAa,SAAS,GAAG;AAAA,IACrC;AAAA,EAC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,CAAC,kBAAkB,UAAU,EAAE,IAC/C,EAAE,eAAe,kBAAkB,WAAW;AAAA,MAClD,iBAAiB,kBAAkB;AAAA,IACrC,CAAC;AAKD,UAAM,eAAe,KAClB,uBAAuB,SAAS,GAC/B,qBAAqBC,YAAW,sBAAsB;AAE1D,QAAI;AAAc,mBAAa,WAAW,UAAU;AAEpD,SAAK,WAAW,KAAK,eAAe;AACpC,UAAM,KAAK,KAAK;AAAA,EAClB;AACF;","names":["fileURLToPath","Node","Project","SyntaxKind","Project","fileURLToPath","SyntaxKind","Node"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { AppEnvironments } from '@adonisjs/application/types';
|
|
3
|
+
import { Project } from 'ts-morph';
|
|
4
|
+
/**
|
|
5
|
+
* RcFileTransformer is used to transform the `adonisrc.ts` file
|
|
6
|
+
* for adding new commands, providers, meta files etc
|
|
7
|
+
*/
|
|
8
|
+
export declare class RcFileTransformer {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(cwd: URL, project: Project);
|
|
11
|
+
/**
|
|
12
|
+
* Add a new command to the rcFile
|
|
13
|
+
*/
|
|
14
|
+
addCommand(commandPath: string): this;
|
|
15
|
+
/**
|
|
16
|
+
* Add a new preloaded file to the rcFile
|
|
17
|
+
*/
|
|
18
|
+
addPreloadFile(modulePath: string, environments?: AppEnvironments[]): this;
|
|
19
|
+
/**
|
|
20
|
+
* Add a new provider to the rcFile
|
|
21
|
+
*/
|
|
22
|
+
addProvider(providerPath: string, environments?: AppEnvironments[]): this;
|
|
23
|
+
/**
|
|
24
|
+
* Add a new meta file to the rcFile
|
|
25
|
+
*/
|
|
26
|
+
addMetaFile(globPattern: string, reloadServer?: boolean): this;
|
|
27
|
+
/**
|
|
28
|
+
* Set directory name and path
|
|
29
|
+
*/
|
|
30
|
+
setDirectory(key: string, value: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Set command alias
|
|
33
|
+
*/
|
|
34
|
+
setCommandAlias(alias: string, command: string): this;
|
|
35
|
+
/**
|
|
36
|
+
* Add a new test suite to the rcFile
|
|
37
|
+
*/
|
|
38
|
+
addSuite(suiteName: string, files: string | string[], timeout?: number): this;
|
|
39
|
+
/**
|
|
40
|
+
* Save the adonisrc.ts file
|
|
41
|
+
*/
|
|
42
|
+
save(): Promise<void>;
|
|
43
|
+
}
|
|
@@ -2,13 +2,45 @@
|
|
|
2
2
|
import type tsStatic from 'typescript';
|
|
3
3
|
import { type Logger } from '@poppinss/cliui';
|
|
4
4
|
import type { DevServerOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Exposes the API to start the development. Optionally, the watch API can be
|
|
7
|
+
* used to watch for file changes and restart the development server.
|
|
8
|
+
*
|
|
9
|
+
* The Dev server performs the following actions
|
|
10
|
+
*
|
|
11
|
+
* - Assigns a random PORT, when PORT inside .env file is in use
|
|
12
|
+
* - Uses tsconfig.json file to collect a list of files to watch.
|
|
13
|
+
* - Uses metaFiles from .adonisrc.json file to collect a list of files to watch.
|
|
14
|
+
* - Restart HTTP server on every file change.
|
|
15
|
+
*/
|
|
5
16
|
export declare class DevServer {
|
|
6
17
|
#private;
|
|
7
18
|
constructor(cwd: URL, options: DevServerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Set a custom CLI UI logger
|
|
21
|
+
*/
|
|
8
22
|
setLogger(logger: Logger): this;
|
|
23
|
+
/**
|
|
24
|
+
* Add listener to get notified when dev server is
|
|
25
|
+
* closed
|
|
26
|
+
*/
|
|
9
27
|
onClose(callback: (exitCode: number) => any): this;
|
|
28
|
+
/**
|
|
29
|
+
* Add listener to get notified when dev server exists
|
|
30
|
+
* with an error
|
|
31
|
+
*/
|
|
10
32
|
onError(callback: (error: any) => any): this;
|
|
33
|
+
/**
|
|
34
|
+
* Close watchers and running child processes
|
|
35
|
+
*/
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Start the development server
|
|
39
|
+
*/
|
|
11
40
|
start(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Start the development server in watch mode
|
|
43
|
+
*/
|
|
12
44
|
startAndWatch(ts: typeof tsStatic, options?: {
|
|
13
45
|
poll: boolean;
|
|
14
46
|
}): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { Watcher } from '@poppinss/chokidar-ts';
|
|
4
|
+
import type { RunOptions, WatchOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parses tsconfig.json and prints errors using typescript compiler
|
|
7
|
+
* host
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseConfig(cwd: string | URL, ts: typeof tsStatic): tsStatic.ParsedCommandLine | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Runs a Node.js script as a child process and inherits the stdio streams
|
|
12
|
+
*/
|
|
13
|
+
export declare function runNode(cwd: string | URL, options: RunOptions): import("execa").ExecaChildProcess<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Runs a script as a child process and inherits the stdio streams
|
|
16
|
+
*/
|
|
17
|
+
export declare function run(cwd: string | URL, options: Omit<RunOptions, 'nodeArgs'>): import("execa").ExecaChildProcess<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Watches the file system using tsconfig file
|
|
20
|
+
*/
|
|
21
|
+
export declare function watch(cwd: string | URL, ts: typeof tsStatic, options: WatchOptions): {
|
|
22
|
+
watcher: Watcher;
|
|
23
|
+
chokidar: import("chokidar").FSWatcher;
|
|
24
|
+
} | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Check if file is an .env file
|
|
27
|
+
*/
|
|
28
|
+
export declare function isDotEnvFile(filePath: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the port to use after inspect the dot-env files inside
|
|
31
|
+
* a given directory.
|
|
32
|
+
*
|
|
33
|
+
* A random port is used when the specified port is in use. Following
|
|
34
|
+
* is the logic for finding a specified port.
|
|
35
|
+
*
|
|
36
|
+
* - The "process.env.PORT" value is used if exists.
|
|
37
|
+
* - The dot-env files are loaded using the "EnvLoader" and the PORT
|
|
38
|
+
* value is by iterating over all the loaded files. The iteration
|
|
39
|
+
* stops after first find.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPort(cwd: URL): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to copy files from relative paths or glob
|
|
44
|
+
* patterns
|
|
45
|
+
*/
|
|
46
|
+
export declare function copyFiles(files: string[], cwd: string, outDir: string): Promise<void[]>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { type Logger } from '@poppinss/cliui';
|
|
4
|
+
import type { TestRunnerOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Exposes the API to start the development. Optionally, the watch API can be
|
|
7
|
+
* used to watch for file changes and restart the development server.
|
|
8
|
+
*
|
|
9
|
+
* The Dev server performs the following actions
|
|
10
|
+
*
|
|
11
|
+
* - Assigns a random PORT, when PORT inside .env file is in use
|
|
12
|
+
* - Uses tsconfig.json file to collect a list of files to watch.
|
|
13
|
+
* - Uses metaFiles from .adonisrc.json file to collect a list of files to watch.
|
|
14
|
+
* - Restart HTTP server on every file change.
|
|
15
|
+
*/
|
|
16
|
+
export declare class TestRunner {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(cwd: URL, options: TestRunnerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Set a custom CLI UI logger
|
|
21
|
+
*/
|
|
22
|
+
setLogger(logger: Logger): this;
|
|
23
|
+
/**
|
|
24
|
+
* Add listener to get notified when dev server is
|
|
25
|
+
* closed
|
|
26
|
+
*/
|
|
27
|
+
onClose(callback: (exitCode: number) => any): this;
|
|
28
|
+
/**
|
|
29
|
+
* Add listener to get notified when dev server exists
|
|
30
|
+
* with an error
|
|
31
|
+
*/
|
|
32
|
+
onError(callback: (error: any) => any): this;
|
|
33
|
+
/**
|
|
34
|
+
* Close watchers and running child processes
|
|
35
|
+
*/
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Runs tests
|
|
39
|
+
*/
|
|
40
|
+
run(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Run tests in watch mode
|
|
43
|
+
*/
|
|
44
|
+
runAndWatch(ts: typeof tsStatic, options?: {
|
|
45
|
+
poll: boolean;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/**
|
|
3
|
+
* Options needed to run a script file
|
|
4
|
+
*/
|
|
2
5
|
export type RunOptions = {
|
|
3
6
|
script: string;
|
|
4
7
|
scriptArgs: string[];
|
|
@@ -6,22 +9,43 @@ export type RunOptions = {
|
|
|
6
9
|
stdio?: 'pipe' | 'inherit';
|
|
7
10
|
env?: NodeJS.ProcessEnv;
|
|
8
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Watcher options
|
|
14
|
+
*/
|
|
9
15
|
export type WatchOptions = {
|
|
10
16
|
poll?: boolean;
|
|
11
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Meta file config defined in ".adonisrc.json" file
|
|
20
|
+
*/
|
|
12
21
|
export type MetaFile = {
|
|
13
22
|
pattern: string;
|
|
14
23
|
reloadServer: boolean;
|
|
15
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Test suite defined in ".adonisrc.json" file
|
|
27
|
+
*/
|
|
28
|
+
export type Suite = {
|
|
29
|
+
files: string | string[];
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Options accepted by assets bundler
|
|
34
|
+
*/
|
|
16
35
|
export type AssetsBundlerOptions = {
|
|
17
36
|
serve: false;
|
|
37
|
+
args?: string[];
|
|
18
38
|
driver?: string;
|
|
19
39
|
cmd?: string;
|
|
20
40
|
} | {
|
|
21
41
|
serve: true;
|
|
42
|
+
args: string[];
|
|
22
43
|
driver: string;
|
|
23
44
|
cmd: string;
|
|
24
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Options accepted by the dev server
|
|
48
|
+
*/
|
|
25
49
|
export type DevServerOptions = {
|
|
26
50
|
scriptArgs: string[];
|
|
27
51
|
nodeArgs: string[];
|
|
@@ -30,7 +54,85 @@ export type DevServerOptions = {
|
|
|
30
54
|
metaFiles?: MetaFile[];
|
|
31
55
|
assets?: AssetsBundlerOptions;
|
|
32
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Options accepted by the test runner
|
|
59
|
+
*/
|
|
60
|
+
export type TestRunnerOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Filter arguments are provided as a key-value
|
|
63
|
+
* pair, so that we can mutate them (if needed)
|
|
64
|
+
*/
|
|
65
|
+
filters: Partial<{
|
|
66
|
+
tests: string[];
|
|
67
|
+
suites: string[];
|
|
68
|
+
groups: string[];
|
|
69
|
+
files: string[];
|
|
70
|
+
tags: string[];
|
|
71
|
+
}>;
|
|
72
|
+
reporters?: string[];
|
|
73
|
+
timeout?: number;
|
|
74
|
+
retries?: number;
|
|
75
|
+
failed?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* All other tags are provided as a collection of
|
|
78
|
+
* arguments
|
|
79
|
+
*/
|
|
80
|
+
scriptArgs: string[];
|
|
81
|
+
nodeArgs: string[];
|
|
82
|
+
clearScreen?: boolean;
|
|
83
|
+
env?: NodeJS.ProcessEnv;
|
|
84
|
+
metaFiles?: MetaFile[];
|
|
85
|
+
assets?: AssetsBundlerOptions;
|
|
86
|
+
suites: Suite[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Options accepted by the project bundler
|
|
90
|
+
*/
|
|
33
91
|
export type BundlerOptions = {
|
|
34
92
|
metaFiles?: MetaFile[];
|
|
35
93
|
assets?: AssetsBundlerOptions;
|
|
36
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Entry to add a middleware to a given middleware stack
|
|
97
|
+
* via the CodeTransformer
|
|
98
|
+
*/
|
|
99
|
+
export type AddMiddlewareEntry = {
|
|
100
|
+
/**
|
|
101
|
+
* If you are adding a named middleware, then you must
|
|
102
|
+
* define the name.
|
|
103
|
+
*/
|
|
104
|
+
name?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The path to the middleware file
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* `@adonisjs/static/static_middleware`
|
|
110
|
+
* `#middlewares/silent_auth.js`
|
|
111
|
+
*/
|
|
112
|
+
path: string;
|
|
113
|
+
/**
|
|
114
|
+
* The position to add the middleware. If `before`
|
|
115
|
+
* middleware will be added at the first position and
|
|
116
|
+
* therefore will be run before all others
|
|
117
|
+
*
|
|
118
|
+
* @default 'after'
|
|
119
|
+
*/
|
|
120
|
+
position?: 'before' | 'after';
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Defines the structure of an environment variable validation
|
|
124
|
+
* definition
|
|
125
|
+
*/
|
|
126
|
+
export type EnvValidationDefinition = {
|
|
127
|
+
/**
|
|
128
|
+
* Write a leading comment on top of your variables
|
|
129
|
+
*/
|
|
130
|
+
leadingComment?: string;
|
|
131
|
+
/**
|
|
132
|
+
* A key-value pair of env variables and their validation
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* MY_VAR: 'Env.schema.string.optional()'
|
|
136
|
+
*/
|
|
137
|
+
variables: Record<string, string>;
|
|
138
|
+
};
|
package/package.json
CHANGED
|
@@ -1,78 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "6.1.3-3",
|
|
4
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
+
"version": "6.1.3-30",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18.16.0"
|
|
7
|
+
},
|
|
5
8
|
"main": "build/index.js",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"files": [
|
|
8
|
-
"build
|
|
9
|
-
"build/
|
|
10
|
-
"build/
|
|
11
|
+
"build",
|
|
12
|
+
"!build/bin",
|
|
13
|
+
"!build/tests"
|
|
11
14
|
],
|
|
12
15
|
"exports": {
|
|
13
16
|
".": "./build/index.js",
|
|
17
|
+
"./code_transformer": "./build/src/code_transformer/main.js",
|
|
14
18
|
"./types": "./build/src/types.js"
|
|
15
19
|
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"pretest": "npm run lint",
|
|
18
|
-
"test": "
|
|
22
|
+
"test": "c8 npm run quick:test",
|
|
19
23
|
"lint": "eslint . --ext=.ts",
|
|
20
24
|
"clean": "del-cli build",
|
|
21
|
-
"
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"precompile": "npm run lint && npm run clean",
|
|
27
|
+
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
|
|
22
28
|
"build": "npm run compile",
|
|
23
29
|
"release": "np",
|
|
24
30
|
"version": "npm run build",
|
|
25
31
|
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/assembler",
|
|
26
32
|
"format": "prettier --write .",
|
|
27
33
|
"prepublishOnly": "npm run build",
|
|
28
|
-
"
|
|
34
|
+
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --loader=ts-node/esm bin/test.ts"
|
|
29
35
|
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"adonisjs",
|
|
32
|
-
"build",
|
|
33
|
-
"ts"
|
|
34
|
-
],
|
|
35
|
-
"author": "virk,adonisjs",
|
|
36
|
-
"license": "MIT",
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@japa/
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
37
|
+
"@adonisjs/application": "^8.0.0-3",
|
|
38
|
+
"@adonisjs/eslint-config": "^1.2.0",
|
|
39
|
+
"@adonisjs/prettier-config": "^1.2.0",
|
|
40
|
+
"@adonisjs/tsconfig": "^1.2.0",
|
|
41
|
+
"@commitlint/cli": "^18.4.3",
|
|
42
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
43
|
+
"@japa/assert": "^2.1.0",
|
|
44
|
+
"@japa/file-system": "^2.1.0",
|
|
45
|
+
"@japa/runner": "^3.1.1",
|
|
46
|
+
"@japa/snapshot": "^2.0.4",
|
|
47
|
+
"@swc/core": "^1.3.101",
|
|
48
|
+
"@types/node": "^20.10.5",
|
|
49
|
+
"@types/picomatch": "^2.3.3",
|
|
50
|
+
"@types/pretty-hrtime": "^1.0.3",
|
|
51
|
+
"c8": "^8.0.1",
|
|
48
52
|
"cross-env": "^7.0.3",
|
|
53
|
+
"dedent": "^1.5.1",
|
|
49
54
|
"del-cli": "^5.0.0",
|
|
50
|
-
"eslint": "^8.
|
|
51
|
-
"eslint-config-prettier": "^8.7.0",
|
|
52
|
-
"eslint-plugin-adonis": "^3.0.3",
|
|
53
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
55
|
+
"eslint": "^8.56.0",
|
|
54
56
|
"github-label-sync": "^2.3.1",
|
|
55
57
|
"husky": "^8.0.3",
|
|
56
|
-
"np": "^
|
|
57
|
-
"p-event": "^
|
|
58
|
-
"prettier": "^
|
|
59
|
-
"ts-node": "^10.9.
|
|
60
|
-
"
|
|
58
|
+
"np": "^9.2.0",
|
|
59
|
+
"p-event": "^6.0.0",
|
|
60
|
+
"prettier": "^3.1.1",
|
|
61
|
+
"ts-node": "^10.9.2",
|
|
62
|
+
"tsup": "^8.0.1",
|
|
63
|
+
"typescript": "^5.3.3"
|
|
61
64
|
},
|
|
62
65
|
"dependencies": {
|
|
63
|
-
"@adonisjs/env": "^4.2.0-
|
|
64
|
-
"@
|
|
65
|
-
"@poppinss/
|
|
66
|
-
"@
|
|
67
|
-
"cpy": "^
|
|
68
|
-
"execa": "^
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
66
|
+
"@adonisjs/env": "^4.2.0-7",
|
|
67
|
+
"@antfu/install-pkg": "^0.3.1",
|
|
68
|
+
"@poppinss/chokidar-ts": "^4.1.3",
|
|
69
|
+
"@poppinss/cliui": "^6.2.3",
|
|
70
|
+
"cpy": "^11.0.0",
|
|
71
|
+
"execa": "^8.0.1",
|
|
72
|
+
"fast-glob": "^3.3.2",
|
|
73
|
+
"get-port": "^7.0.0",
|
|
74
|
+
"junk": "^4.0.1",
|
|
75
|
+
"picomatch": "^3.0.1",
|
|
76
|
+
"pretty-hrtime": "^1.0.3",
|
|
77
|
+
"slash": "^5.1.0",
|
|
78
|
+
"ts-morph": "^21.0.1"
|
|
72
79
|
},
|
|
73
80
|
"peerDependencies": {
|
|
74
81
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
75
82
|
},
|
|
83
|
+
"author": "virk,adonisjs",
|
|
84
|
+
"license": "MIT",
|
|
85
|
+
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
76
86
|
"repository": {
|
|
77
87
|
"type": "git",
|
|
78
88
|
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|
|
@@ -80,37 +90,15 @@
|
|
|
80
90
|
"bugs": {
|
|
81
91
|
"url": "https://github.com/adonisjs/assembler/issues"
|
|
82
92
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
"prettier"
|
|
88
|
-
],
|
|
89
|
-
"plugins": [
|
|
90
|
-
"prettier"
|
|
91
|
-
],
|
|
92
|
-
"rules": {
|
|
93
|
-
"prettier/prettier": [
|
|
94
|
-
"error",
|
|
95
|
-
{
|
|
96
|
-
"endOfLine": "auto"
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"eslintIgnore": [
|
|
102
|
-
"build"
|
|
93
|
+
"keywords": [
|
|
94
|
+
"adonisjs",
|
|
95
|
+
"build",
|
|
96
|
+
"ts"
|
|
103
97
|
],
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"semi": false,
|
|
107
|
-
"singleQuote": true,
|
|
108
|
-
"useTabs": false,
|
|
109
|
-
"quoteProps": "consistent",
|
|
110
|
-
"bracketSpacing": true,
|
|
111
|
-
"arrowParens": "always",
|
|
112
|
-
"printWidth": 100
|
|
98
|
+
"eslintConfig": {
|
|
99
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
113
100
|
},
|
|
101
|
+
"prettier": "@adonisjs/prettier-config",
|
|
114
102
|
"commitlint": {
|
|
115
103
|
"extends": [
|
|
116
104
|
"@commitlint/config-conventional"
|
|
@@ -134,7 +122,22 @@
|
|
|
134
122
|
"exclude": [
|
|
135
123
|
"tests/**",
|
|
136
124
|
"build/**",
|
|
137
|
-
"examples/**"
|
|
125
|
+
"examples/**",
|
|
126
|
+
"src/dev_server.ts",
|
|
127
|
+
"src/test_runner.ts",
|
|
128
|
+
"src/assets_dev_server.ts"
|
|
138
129
|
]
|
|
130
|
+
},
|
|
131
|
+
"tsup": {
|
|
132
|
+
"entry": [
|
|
133
|
+
"./index.ts",
|
|
134
|
+
"./src/code_transformer/main.ts"
|
|
135
|
+
],
|
|
136
|
+
"outDir": "./build",
|
|
137
|
+
"clean": true,
|
|
138
|
+
"format": "esm",
|
|
139
|
+
"dts": false,
|
|
140
|
+
"sourcemap": true,
|
|
141
|
+
"target": "esnext"
|
|
139
142
|
}
|
|
140
143
|
}
|