@adonisjs/assembler 6.1.3-9 → 7.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/README.md +388 -11
- package/build/index.js +999 -11
- package/build/index.js.map +1 -0
- package/build/src/bundler.d.ts +3 -1
- package/build/src/code_transformer/main.d.ts +43 -0
- package/build/src/code_transformer/main.js +454 -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 +2 -2
- package/build/src/helpers.d.ts +7 -6
- package/build/src/test_runner.d.ts +8 -7
- package/build/src/types.d.ts +144 -20
- package/package.json +72 -46
- package/build/src/assets_dev_server.js +0 -158
- package/build/src/bundler.js +0 -223
- package/build/src/dev_server.js +0 -253
- package/build/src/helpers.js +0 -142
- package/build/src/test_runner.js +0 -287
- package/build/src/types.js +0 -9
|
@@ -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 { MiddlewareNode, EnvValidationNode } 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 ensureNewLineAtEndOfFile: true,\n indentStyle: 2,\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: MiddlewareNode) {\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: MiddlewareNode) {\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: EnvValidationNode) {\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(stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]) {\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 importDeclarations: { 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 const existingImports = file.getImportDeclarations()\n\n importDeclarations.forEach((importDeclaration) => {\n const existingImport = existingImports.find(\n (mod) => mod.getModuleSpecifierValue() === importDeclaration.module\n )\n\n /**\n * Add a new named import to existing import for the\n * same module\n */\n if (existingImport && importDeclaration.isNamed) {\n if (\n !existingImport\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === importDeclaration.identifier)\n ) {\n existingImport.addNamedImport(importDeclaration.identifier)\n }\n return\n }\n\n /**\n * Ignore default import when the same module is already imported.\n * The chances are the existing default import and the importDeclaration\n * identifiers are not the same. But we should not modify existing source\n */\n if (existingImport) {\n return\n }\n\n file.addImportDeclaration({\n ...(importDeclaration.isNamed\n ? { namedImports: [importDeclaration.identifier] }\n : { defaultImport: importDeclaration.identifier }),\n moduleSpecifier: importDeclaration.module,\n })\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 /**\n * Add plugin call to the plugins array\n */\n if (pluginsArray) {\n if (!pluginsArray.getElements().find((element) => element.getText() === pluginCall)) {\n pluginsArray.addElement(pluginCall)\n }\n }\n\n file.formatText(this.#editorSettings)\n await file.save()\n }\n}\n","/*\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 { 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 FormatCodeSettings,\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: FormatCodeSettings = {\n indentSize: 2,\n convertTabsToSpaces: true,\n trimTrailingWhitespace: true,\n ensureNewLineAtEndOfFile: true,\n indentStyle: 2,\n // @ts-expect-error SemicolonPreference doesn't seem to be re-exported from ts-morph\n semicolons: 'remove',\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) {\n return false\n }\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;;;ACXP,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EAGA;AAAA,OAKK;AAMA,IAAM,oBAAN,MAAwB;AAAA,EA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AClB,uBAAuB,SAAS,GAC/B,qBAAqBC,YAAW,sBAAsB;AAK1D,QAAI,cAAc;AAChB,UAAI,CAAC,aAAa,YAAY,EAAE,KAAK,CAAC,YAAY,QAAQ,QAAQ,MAAM,UAAU,GAAG;AACnF,qBAAa,WAAW,UAAU;AAAA,MACpC;AAAA,IACF;AAEA,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
|
+
}
|
|
@@ -8,9 +8,9 @@ import type { DevServerOptions } from './types.js';
|
|
|
8
8
|
*
|
|
9
9
|
* The Dev server performs the following actions
|
|
10
10
|
*
|
|
11
|
-
* - Assigns a random PORT, when PORT inside .env file is in use
|
|
11
|
+
* - Assigns a random PORT, when PORT inside .env file is in use.
|
|
12
12
|
* - Uses tsconfig.json file to collect a list of files to watch.
|
|
13
|
-
* - Uses metaFiles from
|
|
13
|
+
* - Uses metaFiles from adonisrc.ts file to collect a list of files to watch.
|
|
14
14
|
* - Restart HTTP server on every file change.
|
|
15
15
|
*/
|
|
16
16
|
export declare class DevServer {
|
package/build/src/helpers.d.ts
CHANGED
|
@@ -26,10 +26,6 @@ export declare function watch(cwd: string | URL, ts: typeof tsStatic, options: W
|
|
|
26
26
|
* Check if file is an .env file
|
|
27
27
|
*/
|
|
28
28
|
export declare function isDotEnvFile(filePath: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Check if file is .adonisrc.json file
|
|
31
|
-
*/
|
|
32
|
-
export declare function isRcFile(filePath: string): boolean;
|
|
33
29
|
/**
|
|
34
30
|
* Returns the port to use after inspect the dot-env files inside
|
|
35
31
|
* a given directory.
|
|
@@ -39,7 +35,12 @@ export declare function isRcFile(filePath: string): boolean;
|
|
|
39
35
|
*
|
|
40
36
|
* - The "process.env.PORT" value is used if exists.
|
|
41
37
|
* - The dot-env files are loaded using the "EnvLoader" and the PORT
|
|
42
|
-
* value is by iterating over all the loaded files. The
|
|
43
|
-
* stops after first find.
|
|
38
|
+
* value is used by iterating over all the loaded files. The
|
|
39
|
+
* iteration stops after first find.
|
|
44
40
|
*/
|
|
45
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[]>;
|
|
@@ -3,15 +3,16 @@ import type tsStatic from 'typescript';
|
|
|
3
3
|
import { type Logger } from '@poppinss/cliui';
|
|
4
4
|
import type { TestRunnerOptions } from './types.js';
|
|
5
5
|
/**
|
|
6
|
-
* Exposes the API to
|
|
7
|
-
*
|
|
6
|
+
* Exposes the API to run Japa tests and optionally watch for file
|
|
7
|
+
* changes to re-run the tests.
|
|
8
8
|
*
|
|
9
|
-
* The
|
|
9
|
+
* The watch mode functions as follows.
|
|
10
|
+
*
|
|
11
|
+
* - If the changed file is a test file, then only tests for that file
|
|
12
|
+
* will be re-run.
|
|
13
|
+
* - Otherwise, all tests will re-run with respect to the initial
|
|
14
|
+
* filters applied when running the `node ace test` command.
|
|
10
15
|
*
|
|
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
|
*/
|
|
16
17
|
export declare class TestRunner {
|
|
17
18
|
#private;
|
package/build/src/types.d.ts
CHANGED
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
* Options needed to run a script file
|
|
4
4
|
*/
|
|
5
5
|
export type RunOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Script to run
|
|
8
|
+
*/
|
|
6
9
|
script: string;
|
|
10
|
+
/**
|
|
11
|
+
* Arguments to pass to the script
|
|
12
|
+
*/
|
|
7
13
|
scriptArgs: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Arguments to pass to NodeJS CLI
|
|
16
|
+
*/
|
|
8
17
|
nodeArgs: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Standard input ouput stream options
|
|
20
|
+
*/
|
|
9
21
|
stdio?: 'pipe' | 'inherit';
|
|
22
|
+
/**
|
|
23
|
+
* Environment variables to pass to the child process
|
|
24
|
+
*/
|
|
10
25
|
env?: NodeJS.ProcessEnv;
|
|
11
26
|
};
|
|
12
27
|
/**
|
|
@@ -16,48 +31,117 @@ export type WatchOptions = {
|
|
|
16
31
|
poll?: boolean;
|
|
17
32
|
};
|
|
18
33
|
/**
|
|
19
|
-
* Meta file config defined in "
|
|
34
|
+
* Meta file config defined in "adonisrc.ts" file
|
|
20
35
|
*/
|
|
21
36
|
export type MetaFile = {
|
|
22
37
|
pattern: string;
|
|
23
38
|
reloadServer: boolean;
|
|
24
39
|
};
|
|
25
40
|
/**
|
|
26
|
-
* Test suite defined in "
|
|
41
|
+
* Test suite defined in "adonisrc.ts" file
|
|
27
42
|
*/
|
|
28
43
|
export type Suite = {
|
|
29
|
-
files: string[];
|
|
30
44
|
name: string;
|
|
45
|
+
files: string | string[];
|
|
31
46
|
};
|
|
32
47
|
/**
|
|
33
48
|
* Options accepted by assets bundler
|
|
34
49
|
*/
|
|
35
50
|
export type AssetsBundlerOptions = {
|
|
36
|
-
|
|
37
|
-
args?: string[];
|
|
51
|
+
enabled: false;
|
|
38
52
|
driver?: string;
|
|
39
53
|
cmd?: string;
|
|
54
|
+
args?: string[];
|
|
40
55
|
} | {
|
|
41
|
-
|
|
42
|
-
args: string[];
|
|
56
|
+
enabled: true;
|
|
43
57
|
driver: string;
|
|
44
58
|
cmd: string;
|
|
59
|
+
args: string[];
|
|
45
60
|
};
|
|
46
61
|
/**
|
|
47
|
-
* Options accepted
|
|
62
|
+
* Options accepted when starting the dev
|
|
63
|
+
* server
|
|
48
64
|
*/
|
|
49
65
|
export type DevServerOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* Arguments to pass to the "bin/server.js" file
|
|
68
|
+
* executed a child process
|
|
69
|
+
*/
|
|
50
70
|
scriptArgs: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Arguments to pass to Node.js CLI when executing
|
|
73
|
+
* the "bin/server.js" file
|
|
74
|
+
*/
|
|
51
75
|
nodeArgs: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Clear screen after every file change
|
|
78
|
+
*/
|
|
52
79
|
clearScreen?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Environment variables to share with the "bin/server.js"
|
|
82
|
+
* file.
|
|
83
|
+
*/
|
|
53
84
|
env?: NodeJS.ProcessEnv;
|
|
85
|
+
/**
|
|
86
|
+
* An array of metaFiles glob patterns to watch
|
|
87
|
+
*/
|
|
54
88
|
metaFiles?: MetaFile[];
|
|
89
|
+
/**
|
|
90
|
+
* Assets bundler options to start its dev server
|
|
91
|
+
*/
|
|
55
92
|
assets?: AssetsBundlerOptions;
|
|
56
93
|
};
|
|
57
94
|
/**
|
|
58
95
|
* Options accepted by the test runner
|
|
59
96
|
*/
|
|
60
97
|
export type TestRunnerOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* Arguments to pass to the "bin/server.js" file
|
|
100
|
+
* executed a child process
|
|
101
|
+
*/
|
|
102
|
+
scriptArgs: string[];
|
|
103
|
+
/**
|
|
104
|
+
* Arguments to pass to Node.js CLI when executing
|
|
105
|
+
* the "bin/server.js" file
|
|
106
|
+
*/
|
|
107
|
+
nodeArgs: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Clear screen after every file change
|
|
110
|
+
*/
|
|
111
|
+
clearScreen?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Environment variables to share with the "bin/server.js"
|
|
114
|
+
* file.
|
|
115
|
+
*/
|
|
116
|
+
env?: NodeJS.ProcessEnv;
|
|
117
|
+
/**
|
|
118
|
+
* An array of metaFiles glob patterns to watch
|
|
119
|
+
*/
|
|
120
|
+
metaFiles?: MetaFile[];
|
|
121
|
+
/**
|
|
122
|
+
* Assets bundler options to start its dev server
|
|
123
|
+
*/
|
|
124
|
+
assets?: AssetsBundlerOptions;
|
|
125
|
+
/**
|
|
126
|
+
* An array of suites for which to run tests
|
|
127
|
+
*/
|
|
128
|
+
suites: Suite[];
|
|
129
|
+
/**
|
|
130
|
+
* Set the tests runner reporter via the CLI flag
|
|
131
|
+
*/
|
|
132
|
+
reporters?: string[];
|
|
133
|
+
/**
|
|
134
|
+
* Set the tests global timeout via the CLI flag
|
|
135
|
+
*/
|
|
136
|
+
timeout?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Define retries via the CLI flag
|
|
139
|
+
*/
|
|
140
|
+
retries?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Run only failed tests
|
|
143
|
+
*/
|
|
144
|
+
failed?: boolean;
|
|
61
145
|
/**
|
|
62
146
|
* Filter arguments are provided as a key-value
|
|
63
147
|
* pair, so that we can mutate them (if needed)
|
|
@@ -68,24 +152,64 @@ export type TestRunnerOptions = {
|
|
|
68
152
|
groups: string[];
|
|
69
153
|
files: string[];
|
|
70
154
|
tags: string[];
|
|
71
|
-
ignoreTags: string[];
|
|
72
155
|
}>;
|
|
73
|
-
/**
|
|
74
|
-
* All other tags are provided as a collection of
|
|
75
|
-
* arguments
|
|
76
|
-
*/
|
|
77
|
-
scriptArgs: string[];
|
|
78
|
-
nodeArgs: string[];
|
|
79
|
-
clearScreen?: boolean;
|
|
80
|
-
env?: NodeJS.ProcessEnv;
|
|
81
|
-
metaFiles?: MetaFile[];
|
|
82
|
-
assets?: AssetsBundlerOptions;
|
|
83
|
-
suites: Suite[];
|
|
84
156
|
};
|
|
85
157
|
/**
|
|
86
158
|
* Options accepted by the project bundler
|
|
87
159
|
*/
|
|
88
160
|
export type BundlerOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* An array of metaFiles glob patterns to copy the
|
|
163
|
+
* files to the build folder
|
|
164
|
+
*/
|
|
89
165
|
metaFiles?: MetaFile[];
|
|
166
|
+
/**
|
|
167
|
+
* Assets bundler options to create the production build
|
|
168
|
+
* for assets
|
|
169
|
+
*/
|
|
90
170
|
assets?: AssetsBundlerOptions;
|
|
91
171
|
};
|
|
172
|
+
/**
|
|
173
|
+
* Entry to add a middleware to a given middleware stack
|
|
174
|
+
* via the CodeTransformer
|
|
175
|
+
*/
|
|
176
|
+
export type MiddlewareNode = {
|
|
177
|
+
/**
|
|
178
|
+
* If you are adding a named middleware, then you must
|
|
179
|
+
* define the name.
|
|
180
|
+
*/
|
|
181
|
+
name?: string;
|
|
182
|
+
/**
|
|
183
|
+
* The path to the middleware file
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* `@adonisjs/static/static_middleware`
|
|
187
|
+
* `#middlewares/silent_auth.js`
|
|
188
|
+
*/
|
|
189
|
+
path: string;
|
|
190
|
+
/**
|
|
191
|
+
* The position to add the middleware. If `before`
|
|
192
|
+
* middleware will be added at the first position and
|
|
193
|
+
* therefore will be run before all others
|
|
194
|
+
*
|
|
195
|
+
* @default 'after'
|
|
196
|
+
*/
|
|
197
|
+
position?: 'before' | 'after';
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Defines the structure of an environment variable validation
|
|
201
|
+
* definition
|
|
202
|
+
*/
|
|
203
|
+
export type EnvValidationNode = {
|
|
204
|
+
/**
|
|
205
|
+
* Write a leading comment on top of your variables
|
|
206
|
+
*/
|
|
207
|
+
leadingComment?: string;
|
|
208
|
+
/**
|
|
209
|
+
* A key-value pair of env variables and their validation
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* MY_VAR: 'Env.schema.string.optional()'
|
|
213
|
+
*/
|
|
214
|
+
variables: Record<string, string>;
|
|
215
|
+
};
|
package/package.json
CHANGED
|
@@ -1,80 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "6.1.3-9",
|
|
4
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
+
"version": "7.0.0-0",
|
|
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
|
-
"engines": {
|
|
17
|
-
"node": ">=18.16.0"
|
|
18
|
-
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"pretest": "npm run lint",
|
|
21
|
-
"test": "
|
|
22
|
+
"test": "c8 npm run quick:test",
|
|
22
23
|
"lint": "eslint . --ext=.ts",
|
|
23
24
|
"clean": "del-cli build",
|
|
24
25
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"
|
|
26
|
+
"precompile": "npm run lint && npm run clean",
|
|
27
|
+
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
|
|
26
28
|
"build": "npm run compile",
|
|
27
29
|
"release": "np",
|
|
28
30
|
"version": "npm run build",
|
|
29
31
|
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/assembler",
|
|
30
32
|
"format": "prettier --write .",
|
|
31
33
|
"prepublishOnly": "npm run build",
|
|
32
|
-
"quick:test": "node --loader=ts-node/esm bin/test.ts"
|
|
34
|
+
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --loader=ts-node/esm bin/test.ts"
|
|
33
35
|
},
|
|
34
|
-
"keywords": [
|
|
35
|
-
"adonisjs",
|
|
36
|
-
"build",
|
|
37
|
-
"ts"
|
|
38
|
-
],
|
|
39
|
-
"author": "virk,adonisjs",
|
|
40
|
-
"license": "MIT",
|
|
41
36
|
"devDependencies": {
|
|
42
|
-
"@adonisjs/
|
|
43
|
-
"@adonisjs/
|
|
44
|
-
"@adonisjs/
|
|
45
|
-
"@
|
|
46
|
-
"@commitlint/
|
|
47
|
-
"@
|
|
48
|
-
"@japa/
|
|
49
|
-
"@japa/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
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",
|
|
54
52
|
"cross-env": "^7.0.3",
|
|
53
|
+
"dedent": "^1.5.1",
|
|
55
54
|
"del-cli": "^5.0.0",
|
|
56
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.56.0",
|
|
57
56
|
"github-label-sync": "^2.3.1",
|
|
58
57
|
"husky": "^8.0.3",
|
|
59
|
-
"np": "^
|
|
58
|
+
"np": "^9.2.0",
|
|
60
59
|
"p-event": "^6.0.0",
|
|
61
|
-
"prettier": "^
|
|
62
|
-
"ts-node": "^10.9.
|
|
63
|
-
"
|
|
60
|
+
"prettier": "^3.1.1",
|
|
61
|
+
"ts-node": "^10.9.2",
|
|
62
|
+
"tsup": "^8.0.1",
|
|
63
|
+
"typescript": "^5.3.3"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@adonisjs/env": "^4.2.0-
|
|
67
|
-
"@
|
|
68
|
-
"@poppinss/
|
|
69
|
-
"
|
|
70
|
-
"
|
|
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",
|
|
71
73
|
"get-port": "^7.0.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
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"
|
|
74
79
|
},
|
|
75
80
|
"peerDependencies": {
|
|
76
81
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
77
82
|
},
|
|
83
|
+
"author": "virk,adonisjs",
|
|
84
|
+
"license": "MIT",
|
|
85
|
+
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
78
86
|
"repository": {
|
|
79
87
|
"type": "git",
|
|
80
88
|
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|
|
@@ -82,7 +90,15 @@
|
|
|
82
90
|
"bugs": {
|
|
83
91
|
"url": "https://github.com/adonisjs/assembler/issues"
|
|
84
92
|
},
|
|
85
|
-
"
|
|
93
|
+
"keywords": [
|
|
94
|
+
"adonisjs",
|
|
95
|
+
"build",
|
|
96
|
+
"ts"
|
|
97
|
+
],
|
|
98
|
+
"eslintConfig": {
|
|
99
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
100
|
+
},
|
|
101
|
+
"prettier": "@adonisjs/prettier-config",
|
|
86
102
|
"commitlint": {
|
|
87
103
|
"extends": [
|
|
88
104
|
"@commitlint/config-conventional"
|
|
@@ -106,14 +122,24 @@
|
|
|
106
122
|
"exclude": [
|
|
107
123
|
"tests/**",
|
|
108
124
|
"build/**",
|
|
125
|
+
"bin/**",
|
|
126
|
+
"tmp/**",
|
|
109
127
|
"examples/**",
|
|
110
128
|
"src/dev_server.ts",
|
|
111
129
|
"src/test_runner.ts",
|
|
112
130
|
"src/assets_dev_server.ts"
|
|
113
131
|
]
|
|
114
132
|
},
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
"tsup": {
|
|
134
|
+
"entry": [
|
|
135
|
+
"./index.ts",
|
|
136
|
+
"./src/code_transformer/main.ts"
|
|
137
|
+
],
|
|
138
|
+
"outDir": "./build",
|
|
139
|
+
"clean": true,
|
|
140
|
+
"format": "esm",
|
|
141
|
+
"dts": false,
|
|
142
|
+
"sourcemap": true,
|
|
143
|
+
"target": "esnext"
|
|
144
|
+
}
|
|
119
145
|
}
|