Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/application

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/application - npm Package Compare versions

Comparing version 6.8.1-0 to 7.0.0-0

build/src/exceptions.d.ts

2

build/index.d.ts

@@ -1,3 +0,3 @@

export * as errors from './src/exceptions/main.js';
export * as errors from './src/exceptions.js';
export { Application } from './src/application.js';
export { RcFileParser } from './src/rc_file_parser.js';

@@ -1,3 +0,3 @@

export * as errors from './src/exceptions/main.js';
export * as errors from './src/exceptions.js';
export { Application } from './src/application.js';
export { RcFileParser } from './src/rc_file_parser.js';

@@ -6,6 +6,7 @@ /// <reference types="node" resolution-mode="require"/>

import { StubsManager } from './stubs/manager.js';
import type { SemverNode, AppEnvironments, ApplicationStates } from './types.js';
import type { Importer, SemverNode, AppEnvironments, ApplicationStates } from './types.js';
export declare class Application<ContainerBindings extends Record<any, any>> {
#private;
get appName(): string;
info: Map<'appName' | 'version' | 'adonisVersion' | string, any>;
get appName(): any;
get version(): SemverNode | null;

@@ -65,2 +66,3 @@ get adonisVersion(): SemverNode | null;

environment: AppEnvironments;
importer: Importer;
});

@@ -81,2 +83,3 @@ getEnvironment(): AppEnvironments;

init(): Promise<void>;
booting(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;
boot(): Promise<void>;

@@ -114,2 +117,6 @@ booted(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): Promise<void>;

listenersPath(...paths: string[]): string;
import(moduleIdentifier: string): any;
importDefault<T extends object>(moduleIdentifier: string): Promise<T extends {
default: infer A;
} ? A : never>;
toJSON(): {

@@ -120,3 +127,3 @@ isReady: boolean;

nodeEnvironment: string;
appName: string;
appName: any;
version: string | null;

@@ -123,0 +130,0 @@ adonisVersion: string | null;

@@ -5,3 +5,3 @@ import Hooks from '@poppinss/hooks';

import { Container } from '@adonisjs/fold';
import { RuntimeException } from '@poppinss/utils';
import { importDefault, RuntimeException } from '@poppinss/utils';
import debug from './debug.js';

@@ -15,4 +15,4 @@ import generators from './generators.js';

import { ProvidersManager } from './managers/providers.js';
import { MetaDataManager } from './managers/meta_data.js';
export class Application {
#importer;
#terminating = false;

@@ -28,14 +28,14 @@ #surroundedEnvironment = {

#nodeEnvManager;
#metaDataManager;
#preloadsManager;
#providersManager;
#hooks = new Hooks();
info = new Map();
get appName() {
return this.#metaDataManager.appName;
return this.info.get('appName') || 'adonisjs_app';
}
get version() {
return this.#metaDataManager.version;
return this.info.get('version') || null;
}
get adonisVersion() {
return this.#metaDataManager.adonisVersion;
return this.info.get('adonisVersion') || null;
}

@@ -85,2 +85,3 @@ get appRoot() {

this.#appRoot = appRoot;
this.#importer = options.importer;
this.#environment = options.environment;

@@ -90,8 +91,7 @@ this.#nodeEnvManager = new NodeEnvManager();

this.#rcFileManager = new RcFileManager(this.appRoot);
this.#metaDataManager = new MetaDataManager(this.appRoot);
this.#providersManager = new ProvidersManager(this.appRoot, {
this.#providersManager = new ProvidersManager(options.importer, {
environment: this.#environment,
providersState: [this],
});
this.#preloadsManager = new PreloadsManager(this.appRoot, {
this.#preloadsManager = new PreloadsManager(options.importer, {
environment: this.#environment,

@@ -175,13 +175,12 @@ });

this.#instantiateContainer();
await this.#metaDataManager.process();
await this.#metaDataManager.verifyNodeEngine();
this.#metaDataManager.addMetaDataToEnv();
await this.#hooks.runner('initiating').run(this);
await this.#rcFileManager.process();
this.#nodeEnvManager.process();
this.#instantiateStubsManager();
await this.#configManager.process(this.rcFile.directories.config);
this.#hooks.clear('initiating');
this.#state = 'initiated';
}
booting(handler) {
this.#hooks.add('booting', handler);
return this;
}
async boot() {

@@ -193,2 +192,6 @@ if (this.#state !== 'initiated') {

debug('booting app');
await this.#hooks.runner('booting').run(this);
this.#hooks.clear('booting');
this.#nodeEnvManager.process();
await this.#configManager.process(this.rcFile.directories.config);
this.#providersManager.use(this.rcFile.providers);

@@ -327,2 +330,8 @@ await this.#providersManager.register();

}
import(moduleIdentifier) {
return this.#importer(moduleIdentifier);
}
importDefault(moduleIdentifier) {
return importDefault(() => this.#importer(moduleIdentifier));
}
toJSON() {

@@ -329,0 +338,0 @@ return {

@@ -9,2 +9,1 @@ /// <reference types="node" resolution-mode="require"/>

export declare function readFileOptional(filePath: URL | string): Promise<string | null>;
export declare function resolveOptional(filePath: string, parent: URL): Promise<string | null>;

@@ -29,13 +29,1 @@ import { join } from 'node:path';

}
export async function resolveOptional(filePath, parent) {
try {
return await import.meta.resolve(filePath, parent);
}
catch (error) {
if (!error.message.includes('Cannot find') &&
!error.message.includes('ERR_PACKAGE_PATH_NOT_EXPORTED')) {
throw error;
}
}
return null;
}

@@ -1,6 +0,5 @@

/// <reference types="node" resolution-mode="require"/>
import type { AppEnvironments, PreloadNode } from '../types.js';
import type { AppEnvironments, Importer, PreloadNode } from '../types.js';
export declare class PreloadsManager {
#private;
constructor(appRoot: URL, options: {
constructor(importer: Importer, options: {
environment: AppEnvironments;

@@ -7,0 +6,0 @@ });

import debug from '../debug.js';
import { resolveOptional } from '../helpers.js';
export class PreloadsManager {
#list = [];
#appRoot;
#importer;
#options;
constructor(appRoot, options) {
this.#appRoot = appRoot;
constructor(importer, options) {
this.#importer = importer;
this.#options = options;

@@ -17,10 +16,4 @@ }

}
async #importPreloadModule(preload) {
if (!preload.optional) {
return import(await import.meta.resolve(preload.file, this.#appRoot));
}
const resolvedPath = await resolveOptional(preload.file, this.#appRoot);
if (resolvedPath) {
await import(resolvedPath);
}
#importPreloadModule(preload) {
return this.#importer(preload.file);
}

@@ -27,0 +20,0 @@ use(list) {

@@ -1,6 +0,5 @@

/// <reference types="node" resolution-mode="require"/>
import type { AppEnvironments, ProviderNode } from '../types.js';
import type { AppEnvironments, Importer, ProviderNode } from '../types.js';
export declare class ProvidersManager {
#private;
constructor(appRoot: URL, options: {
constructor(importer: Importer, options: {
environment: AppEnvironments;

@@ -7,0 +6,0 @@ providersState: any[];

@@ -1,4 +0,3 @@

import { inspect } from 'node:util';
import { importDefault, RuntimeException } from '@poppinss/utils';
import debug from '../debug.js';
import * as errors from '../exceptions/main.js';
export class ProvidersManager {

@@ -8,6 +7,6 @@ #providers = [];

#list = [];
#appRoot;
#importer;
#options;
constructor(appRoot, options) {
this.#appRoot = appRoot;
constructor(importer, options) {
this.#importer = importer;
this.#options = options;

@@ -21,20 +20,14 @@ }

}
#ensureHasDefaultExport(providerPath, providerImport) {
if (!providerImport || typeof providerImport !== 'object' || !providerImport['default']) {
throw new errors.E_MISSING_DEFAULT_EXPORT([providerPath]);
}
}
#ensureIsClass(providerPath, providerClass) {
if (typeof providerClass !== 'function' || !providerClass.toString().startsWith('class ')) {
throw new errors.E_NOT_A_CLASS([inspect(providerClass), providerPath]);
throw new RuntimeException(`Default export from module "${providerPath}" is not a class`);
}
}
async #importProvider(providerPath) {
return import(await import.meta.resolve(providerPath, this.#appRoot));
return importDefault(() => this.#importer(providerPath), providerPath);
}
async #resolveProvider(provider) {
const providerClass = await this.#importProvider(provider.file);
this.#ensureHasDefaultExport(provider.file, providerClass);
this.#ensureIsClass(provider.file, providerClass.default);
return providerClass.default;
this.#ensureIsClass(provider.file, providerClass);
return providerClass;
}

@@ -41,0 +34,0 @@ #resolve() {

import { inspect } from 'node:util';
import * as errors from './exceptions/main.js';
import * as errors from './exceptions.js';
import { directories } from './directories.js';

@@ -42,3 +42,2 @@ export class RcFileParser {

file: normalizedPreload.file,
optional: normalizedPreload.optional ?? false,
environment: normalizedPreload.environment ?? this.#knownEnvironments(),

@@ -45,0 +44,0 @@ };

import { copy } from 'fs-extra';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { RuntimeException, fsReadAll, slash } from '@poppinss/utils';
import { join } from 'node:path';
import { RuntimeException, fsReadAll } from '@poppinss/utils';
import debug from '../debug.js';
import { Stub } from './stub.js';
import { readFileFromSources, resolveOptional } from '../helpers.js';
import { readFileFromSources } from '../helpers.js';
export class StubsManager {

@@ -16,7 +15,7 @@ #app;

async #getPackageSource(packageName) {
const packageJSON = await resolveOptional(slash(join(packageName, 'package.json')), this.#app.appRoot);
if (!packageJSON) {
throw new RuntimeException(`Cannot resolve stubs from package "${packageName}". Make sure the package exports the "package.json" file via exports map`);
const pkgMainExports = await this.#app.import(packageName);
if (!pkgMainExports.stubsRoot) {
throw new RuntimeException(`Cannot resolve stubs from package "${packageName}". Make sure the package entrypoint exports "stubsRoot" variable`);
}
return join(dirname(fileURLToPath(packageJSON)), 'stubs');
return pkgMainExports.stubsRoot;
}

@@ -23,0 +22,0 @@ async build(stubName, options) {

import * as tempura from 'tempura';
import { isAbsolute } from 'node:path';
import string from '@poppinss/utils/string';
import { default as fm } from 'front-matter';
import { pathExists, outputFile } from 'fs-extra';
import string from '@poppinss/utils/string';
import { RuntimeException } from '@poppinss/utils';

@@ -7,0 +7,0 @@ import StringBuilder from '@poppinss/utils/string_builder';

@@ -42,3 +42,2 @@ import type { Application } from './application.js';

environment: Exclude<AppEnvironments, 'unknown'>[];
optional: boolean;
};

@@ -91,1 +90,2 @@ export type ProviderNode = {

}
export type Importer = (moduleIdentifier: string, options?: ImportCallOptions) => any;
/// <reference types="node" resolution-mode="require"/>
import { Application } from '../src/application.js';
import type { AppEnvironments } from '../src/types.js';
import type { AppEnvironments, Importer } from '../src/types.js';
export declare class AppFactory {
#private;
merge(params: Partial<{
options: {
environment: AppEnvironments;
};
environment: AppEnvironments;
importer: Importer;
}>): this;
create(appRoot: URL): Application<Record<any, any>>;
create(appRoot: URL, importer: Importer): Application<Record<any, any>>;
}

@@ -8,5 +8,5 @@ import { Application } from '../src/application.js';

}
create(appRoot) {
return new Application(appRoot, this.#parameters.options || { environment: 'web' });
create(appRoot, importer) {
return new Application(appRoot, Object.assign({ importer }, { environment: 'web' }, this.#parameters));
}
}
# The MIT License
Copyright 2022 Harminder Virk, contributors
Copyright (c) 2023 AdonisJS Framework

@@ -5,0 +5,0 @@ 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:

{
"name": "@adonisjs/application",
"version": "6.8.1-0",
"version": "7.0.0-0",
"description": "AdonisJS application class to read app related data",

@@ -18,3 +18,3 @@ "type": "module",

"./generators": "./build/src/generators.js",
"./test_factories/*": "./build/test_factories/*.js"
"./factories": "./build/test_factories/main.js"
},

@@ -33,3 +33,3 @@ "scripts": {

"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/application",
"vscode:test": "node --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts"
"vscode:test": "node --loader=ts-node/esm bin/test.ts"
},

@@ -43,4 +43,4 @@ "keywords": [

"devDependencies": {
"@adonisjs/config": "^4.1.4-0",
"@adonisjs/fold": "^9.9.1-0",
"@adonisjs/config": "^4.2.0-0",
"@adonisjs/fold": "^9.9.2-0",
"@commitlint/cli": "^17.4.2",

@@ -54,3 +54,3 @@ "@commitlint/config-conventional": "^17.4.2",

"@poppinss/dev-utils": "^2.0.3",
"@swc/core": "^1.3.27",
"@swc/core": "^1.3.29",
"@types/fs-extra": "^11.0.1",

@@ -72,2 +72,3 @@ "@types/node": "^18.11.18",

"prettier": "^2.8.3",
"semver": "^7.3.8",
"ts-dedent": "^2.2.0",

@@ -79,11 +80,10 @@ "ts-node": "^10.9.1",

"@poppinss/hooks": "^7.1.1-0",
"@poppinss/utils": "^6.4.0-0",
"@poppinss/utils": "^6.5.0-0",
"front-matter": "^4.0.2",
"fs-extra": "^11.1.0",
"semver": "^7.3.7",
"tempura": "^0.4.0"
},
"peerDependencies": {
"@adonisjs/config": "^4.1.4-0",
"@adonisjs/fold": "^9.9.1-0"
"@adonisjs/config": "^4.2.0-0",
"@adonisjs/fold": "^9.9.2-0"
},

@@ -90,0 +90,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc