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 1.3.16 to 2.0.0

25

build/adonis-typings/application.d.ts

@@ -19,2 +19,3 @@ declare module '@ioc:Adonis/Core/Application' {

tmp: string;
tests: string;
[key: string]: string;

@@ -28,8 +29,15 @@ }

models: string;
exceptions: string;
middleware: string;
httpControllers: string;
eventListeners: string;
redisListeners: string;
validators: string;
[key: string]: string;
}
/**
* Application environments
*/
export type AppEnvironments = 'web' | 'console' | 'test' | 'unknown';
/**
* Shape of preload files

@@ -39,3 +47,3 @@ */

file: string;
environment: ('web' | 'console' | 'test')[];
environment: Exclude<AppEnvironments, 'unknown'>[];
optional: boolean;

@@ -129,4 +137,15 @@ };

*/
environment: 'web' | 'console' | 'test' | 'unknown';
environment: AppEnvironments;
/**
* Value of `NODE_ENV`. But normalized in certain cases.
*
* - `development` - We normalize `dev`, `develop` to "development"
* - `staging` - We normalize `stage` to "staging"
* - `production` - We normalize `prod` to "production"
* - `testing` - We normalize `test` to "testing"
*
* Rest of the values remains untouched
*/
nodeEnvironment: string;
/**
* A boolean to know if application is ready

@@ -217,3 +236,3 @@ */

isShuttingDown: boolean;
environment: 'web' | 'console' | 'test' | 'unknown';
environment: AppEnvironments;
nodeEnvironment: string;

@@ -220,0 +239,0 @@ appName: string;

14

build/adonis-typings/application.js
/*
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/// <reference path="../adonis-typings/application.d.ts" />
import { RcFile, SemverNode, PreloadNode, ApplicationContract } from '@ioc:Adonis/Core/Application';
import { RcFile, SemverNode, PreloadNode, ApplicationContract, AppEnvironments } from '@ioc:Adonis/Core/Application';
import { IocContract } from '@adonisjs/fold';

@@ -11,2 +11,3 @@ /**

container: IocContract;
private cachedNodeEnv?;
/**

@@ -27,13 +28,5 @@ * A boolean to know if application has bootstrapped successfully

/**
* Is current environment production.
*/
inProduction: boolean;
/**
* Inverse of `inProduction`
*/
inDev: boolean;
/**
* The environment in which application is running
*/
environment: 'web' | 'console' | 'test' | 'unknown';
environment: AppEnvironments;
/**

@@ -55,3 +48,3 @@ * The name of the application picked from `.adonisrc.json` file. This can

*/
directoriesMap: Map<(string), string>;
directoriesMap: Map<string, string>;
/**

@@ -105,4 +98,23 @@ * A map of directories aliases

/**
* Normalizes node env
*/
private normalizeNodeEnv;
/**
* The environment in which application is running
*/
get nodeEnvironment(): string;
/**
* Return true when `this.nodeEnvironment === 'production'`
*/
get inProduction(): boolean;
/**
* Opposite of [[this.isProduction]]
*/
get inDev(): boolean;
/**
* Returns path for a given namespace by replacing the base namespace
* with the defined directories map inside the rc file.
*
* The method returns a relative path from the application root. You can
* use join it with the [[this.appRoot]] to make the absolute path
*/

@@ -133,2 +145,7 @@ resolveNamespaceDirectory(namespaceFor: string): string | null;

* Make path to a file or directory relative from
* the providers path
*/
providersPath(...paths: string[]): string;
/**
* Make path to a file or directory relative from
* the database path

@@ -162,2 +179,6 @@ */

/**
* Makes path to the tests directory
*/
testsPath(...paths: string[]): string;
/**
* Makes path to the tmp directory. Since the tmp path is used for

@@ -174,3 +195,3 @@ * writing at the runtime, we use `cwd` path to the write to the

isShuttingDown: boolean;
environment: "web" | "console" | "test" | "unknown";
environment: AppEnvironments;
nodeEnvironment: string;

@@ -177,0 +198,0 @@ appName: string;

"use strict";
/*
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,2 +16,9 @@ exports.Application = void 0;

/**
* Aliases for different environments
*/
const DEV_ENVS = ['dev', 'develop', 'development'];
const STAGING_ENVS = ['stage', 'staging'];
const PROD_ENVS = ['prod', 'production'];
const TEST_ENVS = ['test', 'testing'];
/**
* The main application instance to know about the environment, filesystem

@@ -39,10 +46,2 @@ * in which your AdonisJs app is running

/**
* Is current environment production.
*/
this.inProduction = process.env.NODE_ENV === 'production';
/**
* Inverse of `inProduction`
*/
this.inDev = !this.inProduction;
/**
* The environment in which application is running

@@ -115,4 +114,57 @@ */

/**
* Normalizes node env
*/
normalizeNodeEnv(env) {
env = env.toLowerCase();
if (DEV_ENVS.includes(env)) {
return 'development';
}
if (STAGING_ENVS.includes(env)) {
return 'staging';
}
if (PROD_ENVS.includes(env)) {
return 'production';
}
if (TEST_ENVS.includes(env)) {
return 'testing';
}
return env;
}
/**
* The environment in which application is running
*/
get nodeEnvironment() {
/**
* If nodeEnv is undefined, then attempt to read the value from `NODE_ENV`
* and cache it (if defined)
*/
if (this.cachedNodeEnv === undefined && process.env.NODE_ENV) {
this.cachedNodeEnv = this.normalizeNodeEnv(process.env.NODE_ENV);
}
/**
* If still undefined
*/
if (this.cachedNodeEnv === undefined) {
return 'unknown';
}
return this.cachedNodeEnv;
}
/**
* Return true when `this.nodeEnvironment === 'production'`
*/
get inProduction() {
return this.nodeEnvironment === 'production';
}
/**
* Opposite of [[this.isProduction]]
*/
get inDev() {
return !this.inProduction;
}
/**
* Returns path for a given namespace by replacing the base namespace
* with the defined directories map inside the rc file.
*
* The method returns a relative path from the application root. You can
* use join it with the [[this.appRoot]] to make the absolute path
*/

@@ -123,3 +175,3 @@ resolveNamespaceDirectory(namespaceFor) {

* entry for namespaces
*/
*/
if (!this.rcFile.namespaces[namespaceFor]) {

@@ -169,2 +221,9 @@ return null;

* Make path to a file or directory relative from
* the providers path
*/
providersPath(...paths) {
return this.makePath(this.directoriesMap.get('providers'), ...paths);
}
/**
* Make path to a file or directory relative from
* the database path

@@ -210,2 +269,8 @@ */

/**
* Makes path to the tests directory
*/
testsPath(...paths) {
return this.makePath(this.directoriesMap.get('tests'), ...paths);
}
/**
* Makes path to the tmp directory. Since the tmp path is used for

@@ -226,3 +291,3 @@ * writing at the runtime, we use `cwd` path to the write to the

environment: this.environment,
nodeEnvironment: this.inProduction ? 'PRODUCTION' : 'DEVELOPMENT',
nodeEnvironment: this.nodeEnvironment,
appName: this.appName,

@@ -229,0 +294,0 @@ version: this.version ? this.version.toString() : null,

"use strict";
/*
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -30,2 +30,3 @@ exports.parse = void 0;

tmp: 'tmp',
tests: 'tests',
};

@@ -37,2 +38,4 @@ /**

models: 'App/Models',
middleware: 'App/Middleware',
exceptions: 'App/Exceptions',
validators: 'App/Validators',

@@ -65,3 +68,3 @@ httpControllers: 'App/Controllers/Http',

preloads: normalizedContents.preloads.map((preload, index) => {
if (typeof (preload) === 'string') {
if (typeof preload === 'string') {
return {

@@ -85,3 +88,3 @@ file: preload,

metaFiles: normalizedContents.metaFiles.map((file, index) => {
if (typeof (file) === 'string') {
if (typeof file === 'string') {
return {

@@ -88,0 +91,0 @@ pattern: file,

"use strict";
/*
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* @adonisjs/application
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -11,0 +11,0 @@ if (k2 === undefined) k2 = k;

# The MIT License
Copyright 2019 Harminder virk, contributors
Copyright 2020 Harminder virk, contributors

@@ -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": "1.3.16",
"description": "AdonisJs application class to read app related data",
"main": "build/standalone.js",
"files": [
"build/adonis-typings",
"build/src",
"build/standalone.d.ts",
"build/standalone.js"
],
"scripts": {
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"pretest": "npm run lint",
"test": "node japaFile.js",
"lint": "eslint . --ext=.ts",
"clean": "del build",
"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile",
"commit": "git-cz",
"release": "np",
"version": "npm run build"
},
"keywords": [
"adonisjs",
"app"
],
"author": "virk,adonisjs",
"license": "MIT",
"devDependencies": {
"@adonisjs/fold": "^6.3.5",
"@adonisjs/mrm-preset": "^2.3.0",
"@types/node": "^14.0.13",
"@types/semver": "^7.2.0",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.2.0",
"del-cli": "^3.0.1",
"doctoc": "^1.4.0",
"eslint": "^7.2.0",
"eslint-plugin-adonis": "^1.0.10",
"husky": "^4.2.5",
"japa": "^3.1.1",
"jsonschema": "^1.2.6",
"mrm": "^2.3.3",
"np": "^6.2.4",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
},
"nyc": {
"exclude": [
"test"
],
"extension": [
".ts"
]
},
"husky": {
"hooks": {
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md",
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"@poppinss/utils": "^2.2.7",
"semver": "^7.3.2"
},
"peerDependencies": {
"@adonisjs/fold": "^6.0.0"
},
"peerDependenciesMeta": {
"@adonisjs/fold": {
"optional": true
}
},
"np": {
"contents": ".",
"anyBranch": false
},
"directories": {
"doc": "docs",
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/adonisjs/application.git"
},
"bugs": {
"url": "https://github.com/adonisjs/application/issues"
},
"homepage": "https://github.com/adonisjs/application#readme"
"name": "@adonisjs/application",
"version": "2.0.0",
"description": "AdonisJS application class to read app related data",
"main": "build/standalone.js",
"files": [
"build/adonis-typings",
"build/src",
"build/standalone.d.ts",
"build/standalone.js"
],
"scripts": {
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"pretest": "npm run lint",
"test": "node japaFile.js",
"clean": "del build",
"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile",
"commit": "git-cz",
"release": "np",
"version": "npm run build",
"prepublishOnly": "npm run build",
"lint": "eslint . --ext=.ts",
"format": "prettier --write .",
"sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json adonisjs/application"
},
"keywords": [
"adonisjs",
"app"
],
"author": "virk,adonisjs",
"license": "MIT",
"devDependencies": {
"@adonisjs/fold": "^6.3.5",
"@adonisjs/mrm-preset": "^2.4.0",
"@types/node": "^14.0.23",
"@types/semver": "^7.3.1",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.2.0",
"del-cli": "^3.0.1",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-adonis": "^1.0.14",
"eslint-plugin-prettier": "^3.1.4",
"github-label-sync": "^2.0.0",
"husky": "^4.2.5",
"japa": "^3.1.1",
"jsonschema": "^1.2.6",
"mrm": "^2.3.3",
"np": "^6.3.2",
"npm-audit-html": "^1.4.1",
"prettier": "^2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
"nyc": {
"exclude": [
"test"
],
"extension": [
".ts"
]
},
"husky": {
"hooks": {
"pre-commit": "npm audit --production --json | ./node_modules/.bin/npm-audit-html && git add npm-audit.html",
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"@poppinss/utils": "^2.3.0",
"semver": "^7.3.2"
},
"peerDependencies": {
"@adonisjs/fold": "^6.0.0"
},
"peerDependenciesMeta": {
"@adonisjs/fold": {
"optional": true
}
},
"np": {
"contents": ".",
"anyBranch": false
},
"directories": {
"doc": "docs",
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/adonisjs/application.git"
},
"bugs": {
"url": "https://github.com/adonisjs/application/issues"
},
"homepage": "https://github.com/adonisjs/application#readme"
}
<div align="center">
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1564392111/adonis-banner_o9lunk.png" width="600px">
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1558612869/adonis-readme_zscycu.jpg" width="600px">
</div>
# Adonis application
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
<br />
The application class for AdonisJs to know more about the environment and project structure of your AdonisJs applications.
<div align="center">
<h3>AdonisJS Application</h3>
<p>The application instance to know/inspect the state of the Application and make paths to certain known directories.</p>
</div>
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of contents
<br />
- [Usage](#usage)
- [rcParser](#rcparser)
- [API Docs](#api-docs)
<div align="center">
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![audit-report-image]][audit-report-url]
## Usage
Ideally you shouldn't be installing this module directly, since it is part of AdonisJs by default. However, installing module directly is helpful when testing AdonisJs specific addons.
</div>
```sh
npm i @adonisjs/application
<div align="center">
<h3>
<a href="https://preview.adonisjs.com">
Website
</a>
<span> | </span>
<a href="https://preview.adonisjs.com/guides/quick-start">
Guides
</a>
<span> | </span>
<a href="CONTRIBUTING.md">
Contributing
</a>
</h3>
</div>
# Yarn
yarn add @adonisjs/application
```
<div align="center">
<sub>Built with ❤︎ by <a href="https://twitter.com/AmanVirk1">Harminder Virk</a>
</div>
and then use it as follows:
```ts
import { Application } from '@adonisjs/application/build/standalone'
import { Ioc } from '@adonisjs/fold'
const app = new Application(
__dirname,
new Ioc(),
require('./adonisrc.json'),
require('./package.json'),
)
```
The constructor takes 4 arguments, which you can fake during tests.
| Argument position | Description |
|------------------|------------------|
| `1 (appRoot)` | The application root |
| `2 (ioc)` | Instance of IoC container |
| `3 (rcContents)` | Contents of `.adonisrc.json` file. You can also provide an empty object |
| `4 (pkgFile)` | Pass the contents of `package.json` file. Required to pull the app name, version and so on |
## rcParser
The application instance will parse the contents of `.adonisrc.json` file. However, if you need the parser, you can access and use it as follows.
```ts
import { rcParser } from '@adonisjs/application/build/standalone'
rcParser.parse(require('.adonisrc.json'))
```
## API Docs
Following are the autogenerated files via Typedoc
* [API](docs/README.md)
[circleci-image]: https://img.shields.io/circleci/project/github/adonisjs/application/master.svg?style=for-the-badge&logo=circleci

@@ -77,1 +51,4 @@ [circleci-url]: https://circleci.com/gh/adonisjs/application "circleci"

[license-url]: LICENSE.md "license"
[audit-report-image]: https://img.shields.io/badge/-Audit%20Report-blueviolet?style=for-the-badge
[audit-report-url]: https://htmlpreview.github.io/?https://github.com/adonisjs/application/blob/develop/npm-audit.html "audit-report"
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