Skip to content

Commit

Permalink
fix(toolkit): add ora to dependencies of toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
why520crazy committed Nov 16, 2023
1 parent 77b50f9 commit 51229a3
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 89 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@typescript-eslint/eslint-plugin": "4.9.1",
"@typescript-eslint/experimental-utils": "4.9.1",
"@typescript-eslint/parser": "5.56.0",
"@worktile/pkg-manager": "^0.0.11",
"@worktile/pkg-manager": "^0.1.0",
"chai": "^4.2.0",
"codelyzer": "^6.0.0",
"coveralls": "^3.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"handlebars": "^4.7.3",
"lodash": "^4.17.21",
"minimatch": "3.0.5",
"ora": "^5.4.1",
"param-case": "^3.0.2",
"pluralize": "^8.0.0",
"shelljs": "0.8.5",
Expand Down
7 changes: 6 additions & 1 deletion packages/toolkit/src/fs/docgeni-fs-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DocgeniHostWatchOptions } from './node-host';
import { FileSystemWatcher, HostWatchEvent } from './watcher';
import { normalize, resolve } from '../path';
import { matchGlob } from '../utils';
import { VfsHost } from './host';

export interface GetDirsOrFilesOptions {
/** Include .dot files in normal matches */
Expand Down Expand Up @@ -32,7 +33,7 @@ export interface DocgeniFsHost {
}

export class DocgeniFsHostImpl implements DocgeniFsHost {
constructor(public readonly host: virtualFs.Host) {}
constructor(public readonly host: virtualFs.Host | VfsHost) {}

async readFile(path: string): Promise<string> {
const data = await this.host.read(normalize(path)).toPromise();
Expand Down Expand Up @@ -153,6 +154,10 @@ export class DocgeniFsHostImpl implements DocgeniFsHost {
}
return result;
}

async mkdir(path: string): Promise<void> {
return (this.host as VfsHost).mkdir(normalize(path));
}
}

export function createDocgeniFsHost(host: virtualFs.Host): DocgeniFsHost {
Expand Down
8 changes: 0 additions & 8 deletions packages/toolkit/src/fs/docgeni-scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ export class DocgeniScopedHost<T extends object> extends virtualFs.ResolverHost<
super(delegate);
}

// protected _resolve(path: Path): Path {
// if (nodePath.isAbsolute(path)) {
// return path;
// } else {
// return nodePath.join(this.root, path) as Path;
// }
// }

protected _resolve(path: Path): Path {
if (isAbsolute(path)) {
return path;
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/fs/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { virtualFs } from '@angular-devkit/core';

export interface VfsHost extends virtualFs.Host {
copy(src: string, dest: string): Promise<void>;
mkdir(path: string): Promise<void>;
}
4 changes: 4 additions & 0 deletions packages/toolkit/src/fs/node-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ export class DocgeniNodeJsAsyncHost extends NodeJsAsyncHost {
const watcher = new FileSystemWatcher(options);
return watcher.watch(path) as Observable<virtualFs.HostWatchEvent>;
}

mkdir(path: Path) {
return fsPromises.mkdir(getSystemPath(path), { recursive: true });
}
}
10 changes: 10 additions & 0 deletions packages/toolkit/src/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import * as strings from './strings';
import * as utils from './utils';
import * as shell from './shell';
import * as git from './git';
import { colors } from './colors';
import { Print } from './print';
import { Spinner } from './spinner';

export interface ToolkitConfig {
baseDir: string;
Expand Down Expand Up @@ -71,4 +73,12 @@ export class Toolkit {
static get path() {
return path;
}

static get colors() {
return colors;
}

static createSpinner(text?: string) {
return new Spinner(text);
}
}

0 comments on commit 51229a3

Please sign in to comment.