Skip to content
Permalink
Browse files

docs: add more comments

  • Loading branch information...
manekinekko committed Aug 6, 2019
1 parent cd1ea58 commit c7182f118adbd44617e3d0790249ad3c477f8ded
@@ -11,6 +11,17 @@ import { Schema as AzureOptions } from '../schema';
const AZURE_STORAGE_SAS_KEY = 'AZURE_STORAGE_SAS_KEY';
const AZURE_STORAGE_ACCOUNT = 'AZURE_STORAGE_ACCOUNT';

/**
* This will create or update the `.env` file with the `AZURE_STORAGE_ACCOUNT` and `AZURE_STORAGE_SAS_KEY` values.
*
* @example
* ```
* AZURE_STORAGE_SAS_KEY=this-is-the-sas-key-value
* AZURE_STORAGE_ACCOUNT=this-is-the-storage-account-value
* ```
*
* @param options The Azure arguments provided to this schematic.
*/
export function addDotEnvConfig(options: AzureOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
const envPath = normalize('/.env');
@@ -77,6 +88,16 @@ function readEnvFile(host: Tree, fileName: string): string {
return buffer ? buffer.toString('utf-8') : null;
}

/**
* This rule is responsible for adding the `require('dotenv').config()` to the main.ts file.
* The call will be added to the top of the file before any other call.
*
* @example
* ```
* if (process.env.NODE_ENV !== 'production') require('dotenv').config();
* ```
* @param options The Azure arguments provided to this schematic.
*/
export function addDotEnvCall(options: AzureOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
const mainFilePath = `${options.rootDir}/${options.mainFileName}.ts`;
@@ -9,7 +9,7 @@
/**
* The content of this file was adjusted based on: https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/ast-utils.ts
* These changes were necessary to make the schematics API work with the NestJS framerwork.
*
*
* @author Wassim Chegham <wassim.dev>
*/

@@ -19,6 +19,24 @@ import { Schema as AzureOptions } from '../schema';
import { addModuleImportToRootModule } from '../utils/ast';
import { hasNestModuleImport } from '../utils/nest-module-import';

/**
* Add the AzureStorageModule.withConfig(...) configuration to the main Nest module.
* This will both import the `AzureStorageModule` from the `@nestjs/azure-storage` package and
* add the `AzureStorageModule.withConfig(...)` to the `imports` entry of the main Nest Module.
*
* @example
* ```
* imports: [
* AzureStorageModule.withConfig({
* sasKey: process.env['AZURE_STORAGE_SAS_KEY'],
* accountName: process.env['AZURE_STORAGE_ACCOUNT'],
* containerName: 'nest-demo-container',
* }),
* ],
* ```
*
* @param options The Azure arguments provided to this schematic.
*/
export function addAzureStorageModuleToImports(options: AzureOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
const MODULE_WITH_CONFIG = `AzureStorageModule.withConfig({sasKey: process.env['AZURE_STORAGE_SAS_KEY'], accountName: process.env['AZURE_STORAGE_ACCOUNT'], containerName: 'nest-demo-container' })`;
@@ -2,6 +2,12 @@ import { Rule, SchematicContext } from '@angular-devkit/schematics';
import { Tree } from '@angular-devkit/schematics/src/tree/interface';
import { Schema as AzureOptions } from '../schema';

/**
* Update the .gitignore file in order to add in the .env file that was created.
* .env file MUST be ingored by GIT sicne they contains sensitive information.
*
* @param options The Azure arguments provided to this schematic.
*/
export function updateGitIgnore(options: AzureOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
const gitIgnorePath = `.gitignore`;

0 comments on commit c7182f1

Please sign in to comment.
You can’t perform that action at this time.