Skip to content

Commit

Permalink
chore(): publish 6.6.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jul 15, 2019
1 parent 2e8956b commit a3f12e0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
35 changes: 32 additions & 3 deletions actions/add.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import {
AbstractPackageManager,
PackageManagerFactory,
} from '../lib/package-managers';
import {
AbstractCollection,
CollectionFactory,
SchematicOption,
} from '../lib/schematics';
import { AbstractAction } from './abstract.action';

export class AddAction extends AbstractAction {
Expand All @@ -11,9 +16,33 @@ export class AddAction extends AbstractAction {
const libraryInput: Input = inputs.find(
input => input.name === 'library',
) as Input;
if (libraryInput) {
const library: string = libraryInput.value as string;
await manager.addProduction([library], 'latest');

if (!libraryInput) {
return;
}
const library: string = libraryInput.value as string;
await manager.addProduction([library], 'latest');

const packageName = library.startsWith('@')
? library.split('/', 2).join('/')
: library.split('/', 1)[0];

// Remove the tag/version from the package name.
const collectionName =
(packageName.startsWith('@')
? packageName.split('@', 2).join('@')
: packageName.split('@', 1).join('@')) +
library.slice(packageName.length);

const schematicName = 'nest-add';
try {
const collection: AbstractCollection = CollectionFactory.create(
collectionName,
);
const schematicOptions: SchematicOption[] = [];
await collection.execute(schematicName, schematicOptions);
} catch (e) {
return;
}
}
}
13 changes: 4 additions & 9 deletions actions/update.action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import chalk from 'chalk';
import { Input } from '../commands';
import { NestDependencyManager } from '../lib/dependency-managers';
import { PackageManagerFactory } from '../lib/package-managers';
Expand All @@ -9,13 +8,9 @@ export class UpdateAction extends AbstractAction {
const force = options.find(option => option.name === 'force') as Input;
const tag = options.find(option => option.name === 'tag') as Input;

if (force.value && tag.value === undefined) {
console.error(chalk.red('You should specify a tag (e.g. latest) on force update.'));
} else {
const manager = new NestDependencyManager(
await PackageManagerFactory.find(),
);
await manager.update(force.value as boolean, tag.value as string);
}
const manager = new NestDependencyManager(
await PackageManagerFactory.find(),
);
await manager.update(force.value as boolean, tag.value as string);
}
}
7 changes: 2 additions & 5 deletions lib/dependency-managers/nest.dependency-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class NestDependencyManager {
.map(dependency => dependency.name);
}

public async update(force: boolean, tag: string) {
public async update(force: boolean, tag: string = 'latest') {
const spinner = ora({
spinner: {
interval: 120,
Expand All @@ -23,10 +23,7 @@ export class NestDependencyManager {
spinner.start();
const dependencies: string[] = await this.read();
if (force) {
await this.packageManager.upgradeProduction(
dependencies,
tag !== undefined ? tag : 'latest',
);
await this.packageManager.upgradeProduction(dependencies, tag);
} else {
await this.packageManager.updateProduction(dependencies);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/schematics/collection.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CustomCollection } from './custom.collection';
import { NestCollection } from './nest.collection';

export class CollectionFactory {
public static create(collection: Collection): AbstractCollection {
public static create(collection: Collection | string): AbstractCollection {
switch (collection) {
case Collection.NESTJS:
return new NestCollection(RunnerFactory.create(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/cli",
"version": "6.5.0",
"version": "6.6.0",
"description": "Nest - modern, fast, powerful node.js web framework (@cli)",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit a3f12e0

Please sign in to comment.