dotenv-run icon indicating copy to clipboard operation
dotenv-run copied to clipboard

Support angular workspace for ng-add

Open aboudard opened this issue 2 years ago • 0 comments

Hello,

When running in an angular workspace, the ng-add command can recognize the proper project for the modifications of the angular.json file. But for the env.d.ts file, this is only a use of src folder, which makes that you have to move the file.

The following move function could use the project path :

export default function (options: any): Rule {
  return chain([
    mergeWith(apply(url("./template"), [move(normalize("./src"))])),
    builder(options),
  ]);
}

This can be helpful when we want to call the schematics from another schematics with externalSchematic method, giving the project as argument :

function addNgxEnvBuilder(): Rule {
	return (tree: Tree, context: SchematicContext) => {
		context.logger.log('info', `🛠 Adding ngx-env builder...`);
		return externalSchematic('@ngx-env/builder', 'ng-add', {
			project: 'sandbox'    //or options.project for example
		})(tree, context);
	}
}

Cheers !

aboudard avatar Oct 16 '23 16:10 aboudard