Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/342: Update deps #343

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,860 changes: 1,418 additions & 1,442 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/azure-storage",
"version": "3.0.0",
"version": "3.1.0",
"description": "An Azure Storage module for Nest framework (node.js)",
"license": "MIT",
"author": "Wassim Chegham",
Expand All @@ -17,15 +17,14 @@
"publish:next": "npm publish --access public --tag next"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.2",
"@nestjs/core": "^8.0.0 || ^9.0.2",
"@nestjs/platform-express": "^8.0.0 || ^9.0.2"
"@nestjs/common": "^10.0.0 || ^11.0.0",
"@nestjs/core": "^10.0.0 || ^11.0.0",
"@nestjs/platform-express": "^10.0.0 || ^11.0.0"
},
"devDependencies": {
"@angular/cdk": "^14.0.4",
"@nestjs/common": "8.4.7",
"@nestjs/core": "8.4.7",
"@nestjs/platform-express": "8.4.7",
"@nestjs/common": "^11.0.0",
"@nestjs/core": "^11.0.0",
"@nestjs/platform-express": "^11.0.0",
"@types/jest": "^29.0.0",
"@types/node": "22.10.7",
"husky": "9.1.7",
Expand All @@ -35,13 +34,12 @@
"prettier": "3.4.2",
"reflect-metadata": "^0.1.13",
"ts-jest": "^29.0.0",
"ts-morph": "25.0.0",
"typescript": "4.9.5"
"typescript": "^5.7.0"
},
"dependencies": {
"@angular-devkit/schematics": "14.2.13",
"@schematics/angular": "14.2.13",
"@angular/cdk": "8.2.3",
"@angular-devkit/schematics": "^19.1.0",
"@schematics/angular": "^19.1.0",
"@angular/cdk": "^19.1.0",
"@azure/storage-blob": "10.5.0"
},
"main": "./dist/index.js",
Expand Down
46 changes: 23 additions & 23 deletions schematics/install/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
invalidAzureOptions.storageAccountName = null;

expect(async () => {
await runner.runSchematicAsync('nest-add', invalidAzureOptions, tree).toPromise();
await runner.runSchematic('nest-add', invalidAzureOptions, tree);
}).rejects.toThrow();
});

Expand All @@ -98,12 +98,12 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
invalidAzureOptions.storageAccountSAS = null;

expect(async () => {
await runner.runSchematicAsync('nest-add', invalidAzureOptions, tree).toPromise();
await runner.runSchematic('nest-add', invalidAzureOptions, tree);
}).rejects.toThrow();
});

it('should create all required files', async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

expect(tree.files).toEqual([
'/package.json',
Expand All @@ -116,7 +116,7 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
});

it('should add all required dependencies to package.json', async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = JSON.parse(tree.readContent('/package.json'));
expect(Object.keys(fileContent.dependencies).sort()).toEqual(
Expand All @@ -130,14 +130,14 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
});

it('should add all required dependencies to package.json even if --skipInstall is used', async () => {
await runner.runSchematicAsync(
await runner.runSchematic(
'nest-add',
{
...azureOptions,
skipInstall: true,
} as AzureOptions,
tree,
).toPromise();
);

const fileContent = JSON.parse(tree.readContent('/package.json'));
expect(fileContent.dependencies).toBeTruthy();
Expand All @@ -147,22 +147,22 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
});

it('should create .gitignore and add .env rules to it', async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/.gitignore');
expect(fileContent).toContain('.env\n.env.*\n');
});

it('should add AZURE_STORAGE_SAS_KEY and AZURE_STORAGE_ACCOUNT config to .env', async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/.env');
expect(fileContent).toContain('AZURE_STORAGE_SAS_KEY=testing');
expect(fileContent).toContain('AZURE_STORAGE_ACCOUNT=testing');
});

it(`should not add the require('dotenv') call in src/main.ts`, async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/src/main.ts');
expect(fileContent).not.toContain(
Expand All @@ -171,51 +171,51 @@ describe('Running nest add @nestjs/azure-storage in a clean project', () => {
});

it(`should add the @nestjs/azure-storage import in src/app.module.ts`, async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/src/app.module.ts');
expect(fileContent).toContain(AZURE_MODULE_IMPORT);
});

it(`should throw if main module is not found`, () => {
expect(async () => {
await runner.runSchematicAsync(
await runner.runSchematic(
'nest-add',
{
...azureOptions,
rootModuleFileName: 'file-404',
} as AzureOptions,
tree,
).toPromise();
);
}).rejects.toThrow('Could not read Nest module file: src/file-404.ts');
});

it(`should not add AzureStorageModule.withConfig(...) call if @Module() is not found`, async () => {
tree.create('/src/app.mpdule.ts', APP_MODULE_CONTENT_NO_DECORATOR);
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const content = tree.readContent('/src/app.mpdule.ts');
expect(content).toMatch(APP_MODULE_CONTENT_NO_DECORATOR);
});

it(`should not add AzureStorageModule.withConfig(...) call if already exists`, async () => {
tree.create('/src/app.mpdule.ts', APP_MODULE_CONTENT_WITH_CONFIG);
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const content = tree.readContent('/src/app.mpdule.ts');
expect(content).toMatch(APP_MODULE_CONTENT_WITH_CONFIG);
});

describe(`should add the AzureStorageModule.withConfig(...) call in src/app.module.ts`, () => {
it(`when "Module.import" is empty array`, async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
const fileContent = tree.readContent('/src/app.module.ts');
expect(fileContent).toContain(AZURE_MODULE_CONFIG);
});

it('when "Module.import" is undefined', async () => {
tree.create('/src/app.mpdule.ts', APP_MODULE_CONTENT_NO_IMPORT);
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
const fileContent = tree.readContent('/src/app.module.ts');
expect(fileContent).toContain(AZURE_MODULE_CONFIG);
});
Expand All @@ -233,7 +233,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {

it('should throw if missing package.json', () => {
expect(async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
}).rejects.toThrow('Path \"/package.json\" does not exist.');
});

Expand All @@ -242,7 +242,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
tree.create('/src/main.ts', MAIN_FILE);

expect(async () => {
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
}).rejects.toThrow('Could not read Nest module file: src/app.module.ts');
});

Expand All @@ -252,7 +252,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
tree.create('/src/app.module.ts', APP_MODULE_CONTENT);
tree.create('/.env', 'old content');

await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
const fileContent = tree.readContent('/.env');
expect(fileContent).toContain('AZURE_STORAGE_SAS_KEY=testing');
expect(fileContent).toContain('AZURE_STORAGE_ACCOUNT=testing');
Expand All @@ -270,7 +270,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
].join('\n');
tree.create('/.env', ENV_CONTENT);

await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);
const fileContent = tree.readContent('/.env');
expect(fileContent).toMatch(ENV_CONTENT);
});
Expand All @@ -280,7 +280,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
tree.create('/src/main.ts', MAIN_FILE);
tree.create('/src/app.module.ts', APP_MODULE_CONTENT);
tree.create('/.gitignore', '.env');
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/.gitignore');
expect(fileContent).toMatch('.env');
Expand All @@ -291,7 +291,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
tree.create('/src/main.ts', MAIN_FILE);
tree.create('/src/app.module.ts', APP_MODULE_CONTENT);
tree.create('/.gitignore', 'foo');
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/.gitignore');
expect(fileContent).toMatch('foo\n.env\n.env.*\n');
Expand All @@ -302,7 +302,7 @@ describe('Running nest add @nestjs/azure-storage in a complex project', () => {
tree.create('/src/main.ts', MAIN_FILE);
tree.create('/src/app.module.ts', APP_MODULE_CONTENT);
tree.create('/.gitignore', '');
await runner.runSchematicAsync('nest-add', azureOptions, tree).toPromise();
await runner.runSchematic('nest-add', azureOptions, tree);

const fileContent = tree.readContent('/.gitignore');
expect(fileContent).toMatch('\n.env\n.env.*\n');
Expand Down
5 changes: 2 additions & 3 deletions schematics/install/src/add-env-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addDotEnvCall = exports.addDotEnvConfig = void 0;
exports.addDotEnvConfig = addDotEnvConfig;
exports.addDotEnvCall = addDotEnvCall;
const core_1 = require("@angular-devkit/core");
const colors_1 = require("../utils/colors");
const schematics_1 = require("@angular-devkit/schematics");
Expand Down Expand Up @@ -47,7 +48,6 @@ function addDotEnvConfig(options) {
return tree;
};
}
exports.addDotEnvConfig = addDotEnvConfig;
function readEnvFile(host, fileName) {
const buffer = host.read(fileName);
return buffer ? buffer.toString('utf-8') : null;
Expand All @@ -73,4 +73,3 @@ function addDotEnvCall(options) {
return tree;
};
}
exports.addDotEnvCall = addDotEnvCall;
3 changes: 1 addition & 2 deletions schematics/install/src/add-module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addAzureStorageModuleToImports = void 0;
exports.addAzureStorageModuleToImports = addAzureStorageModuleToImports;
const core_1 = require("@angular-devkit/core");
const ast_1 = require("../utils/ast");
const nest_module_import_1 = require("../utils/nest-module-import");
Expand All @@ -15,4 +15,3 @@ function addAzureStorageModuleToImports(options) {
return tree;
};
}
exports.addAzureStorageModuleToImports = addAzureStorageModuleToImports;
3 changes: 1 addition & 2 deletions schematics/install/src/update-git-ignore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateGitIgnore = void 0;
exports.updateGitIgnore = updateGitIgnore;
function updateGitIgnore(options) {
return (tree, context) => {
const gitIgnorePath = `.gitignore`;
Expand All @@ -22,4 +22,3 @@ function updateGitIgnore(options) {
return tree;
};
}
exports.updateGitIgnore = updateGitIgnore;
11 changes: 5 additions & 6 deletions schematics/install/utils/ast-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addImportToModule = exports.getMetadataField = exports.addSymbolToNestModuleMetadata = exports.getDecoratorMetadata = void 0;
exports.getDecoratorMetadata = getDecoratorMetadata;
exports.addSymbolToNestModuleMetadata = addSymbolToNestModuleMetadata;
exports.getMetadataField = getMetadataField;
exports.addImportToModule = addImportToModule;
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const change_1 = require("@schematics/angular/utility/change");
const ts = require("typescript");
Expand All @@ -15,7 +18,7 @@ function getDecoratorMetadata(source, identifier, module) {
}, {});
return (0, ast_utils_1.getSourceNodes)(source)
.filter(node => {
return (node.kind == ts.SyntaxKind.Decorator &&
return (ts.isDecorator(node) &&
node.expression.kind == ts.SyntaxKind.CallExpression);
})
.map(node => node.expression)
Expand All @@ -39,7 +42,6 @@ function getDecoratorMetadata(source, identifier, module) {
expr.arguments[0].kind == ts.SyntaxKind.ObjectLiteralExpression)
.map(expr => expr.arguments[0]);
}
exports.getDecoratorMetadata = getDecoratorMetadata;
function _nestImportsFromNode(node, _sourceFile) {
const ms = node.moduleSpecifier;
let modulePath;
Expand Down Expand Up @@ -182,7 +184,6 @@ function addSymbolToNestModuleMetadata(source, ngModulePath, metadataField, symb
}
return [new change_1.InsertChange(ngModulePath, position, toInsert)];
}
exports.addSymbolToNestModuleMetadata = addSymbolToNestModuleMetadata;
function getMetadataField(node, metadataField) {
return (node.properties
.filter(prop => ts.isPropertyAssignment(prop))
Expand All @@ -191,8 +192,6 @@ function getMetadataField(node, metadataField) {
name.getText() === metadataField);
}));
}
exports.getMetadataField = getMetadataField;
function addImportToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNestModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
}
exports.addImportToModule = addImportToModule;
2 changes: 1 addition & 1 deletion schematics/install/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getDecoratorMetadata(
return getSourceNodes(source as any)
.filter(node => {
return (
node.kind == ts.SyntaxKind.Decorator &&
ts.isDecorator(node) &&
(node as any).expression.kind == ts.SyntaxKind.CallExpression
);
})
Expand Down
5 changes: 2 additions & 3 deletions schematics/install/utils/ast.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addModuleImportToModule = exports.addModuleImportToRootModule = void 0;
exports.addModuleImportToRootModule = addModuleImportToRootModule;
exports.addModuleImportToModule = addModuleImportToModule;
const core_1 = require("@angular-devkit/core");
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@angular/cdk/schematics");
Expand All @@ -12,7 +13,6 @@ function addModuleImportToRootModule(options) {
addModuleImportToModule(host, modulePath, moduleName, src);
};
}
exports.addModuleImportToRootModule = addModuleImportToRootModule;
function addModuleImportToModule(host, modulePath, moduleName, src) {
const moduleSource = (0, schematics_2.parseSourceFile)(host, modulePath);
if (!moduleSource) {
Expand All @@ -27,4 +27,3 @@ function addModuleImportToModule(host, modulePath, moduleName, src) {
});
host.commitUpdate(recorder);
}
exports.addModuleImportToModule = addModuleImportToModule;
4 changes: 2 additions & 2 deletions schematics/install/utils/colors.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.green = exports.red = exports.mapObject = void 0;
exports.green = exports.red = void 0;
exports.mapObject = mapObject;
function mapObject(obj, mapper) {
return Object.keys(obj).reduce((acc, k) => {
acc[k] = mapper(k, obj[k]);
return acc;
}, {});
}
exports.mapObject = mapObject;
const kColors = {
modifiers: {
reset: [0, 0],
Expand Down
Loading