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

@adonisjs/assembler

Package Overview
Dependencies
Maintainers
3
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/assembler - npm Package Compare versions

Comparing version 7.0.0-0 to 7.0.0-1

7

build/src/code_transformer/main.d.ts
/// <reference types="node" resolution-mode="require"/>
import { installPackage, detectPackageManager } from '@antfu/install-pkg';
import { RcFileTransformer } from './rc_file_transformer.js';
import type { MiddlewareNode, EnvValidationNode } from '../types.js';
import type { MiddlewareNode, EnvValidationNode, BouncerPolicyNode } from '../types.js';
/**

@@ -43,2 +43,7 @@ * This class is responsible for updating

}[]): Promise<void>;
/**
* Adds a policy to the list of `policies` object configured
* inside the `app/policies/main.ts` file.
*/
addPolicies(policies: BouncerPolicyNode[]): Promise<void>;
}

@@ -341,2 +341,13 @@ // src/code_transformer/main.ts

/**
* Add a policy to the list of pre-registered policy
*/
#addToPoliciesList(file, policyEntry) {
const policiesObject = file.getVariableDeclarationOrThrow("policies").getInitializerIfKindOrThrow(SyntaxKind2.ObjectLiteralExpression);
const existingProperty = policiesObject.getProperty(policyEntry.name);
if (!existingProperty) {
const policy = `${policyEntry.name}: () => import('${policyEntry.path}')`;
policiesObject.insertProperty(0, policy);
}
}
/**
* Write a leading comment

@@ -451,2 +462,15 @@ */

}
/**
* Adds a policy to the list of `policies` object configured
* inside the `app/policies/main.ts` file.
*/
async addPolicies(policies) {
const kernelUrl = fileURLToPath2(new URL("./app/policies/main.ts", this.#cwd));
const file = this.#project.getSourceFileOrThrow(kernelUrl);
for (const policy of policies) {
this.#addToPoliciesList(file, policy);
}
file.formatText(this.#editorSettings);
await file.save();
}
};

@@ -453,0 +477,0 @@ export {

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

/**
* Policy node to be added to the list of policies.
*/
export type BouncerPolicyNode = {
/**
* Policy name
*/
name: string;
/**
* Policy import path
*/
path: string;
};
/**
* Defines the structure of an environment variable validation

@@ -202,0 +215,0 @@ * definition

2

package.json
{
"name": "@adonisjs/assembler",
"description": "Provides utilities to run AdonisJS development server and build project for production",
"version": "7.0.0-0",
"version": "7.0.0-1",
"engines": {

@@ -6,0 +6,0 @@ "node": ">=18.16.0"

@@ -393,2 +393,32 @@ # @adonisjs/assembler

### addPolicies
Register AdonisJS bouncer policies to the list of `policies` object exported from the `app/policies/main.ts` file.
> [!IMPORTANT]
> This codemod expects the `app/policies/main.ts` file to exist and must export a `policies` object from it.
```ts
const transformer = new CodeTransformer(appRoot)
try {
await transformer.addPolicies([
{
name: 'PostPolicy',
path: '#policies/post_policy'
}
])
} catch (error) {
console.error('Unable to register policy')
console.error(error)
}
```
Output
```ts
export const policies = {
UserPolicy: () => import('#policies/post_policy')
}
```
## Contributing

@@ -395,0 +425,0 @@ One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believe in the framework's principles.

Sorry, the diff of this file is not supported yet

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