-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d1bf23
commit af73567
Showing
5 changed files
with
45 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { CAC } from 'cac'; | ||
import fs from 'fs-extra'; | ||
import enquirer from 'enquirer'; | ||
|
||
import chalk from 'chalk'; | ||
import { CLIUtils } from './utils'; | ||
import consola from 'consola'; | ||
|
||
export default function useCachePackage(cli: CAC) { | ||
cli | ||
.command('cache', 'cache current workspace packages to cache directory') | ||
.action(async () => { | ||
fs.ensureDirSync(CLIUtils.resolvedPackageRootDir); | ||
const existPackages = CLIUtils.existPackages; | ||
|
||
for (const p of existPackages) { | ||
const projectSrcPath = CLIUtils.resolvePackageDir(p); | ||
|
||
const projectDestPath = CLIUtils.resolveCachePackageDir(p); | ||
|
||
if (fs.existsSync(projectDestPath)) continue; | ||
|
||
fs.copySync(projectSrcPath, projectDestPath, { | ||
recursive: true, | ||
filter: (src, dest) => { | ||
const filtered = ['node_modules', 'dist', 'tmp'].every( | ||
(pattern) => !src.includes(pattern) | ||
); | ||
|
||
return filtered; | ||
}, | ||
}); | ||
|
||
consola.success(`Package ${chalk.green(p)} cached.`); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,5 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
import { CLIUtils, Constants } from './utils'; | ||
|
||
export class CLIHooks { | ||
public static pre() { | ||
fs.ensureDirSync(CLIUtils.resolvedPackageRootDir); | ||
const existPackages = CLIUtils.existPackages; | ||
|
||
for (const p of existPackages.slice(0)) { | ||
const projectSrcPath = CLIUtils.resolvePackageDir(p); | ||
|
||
const projectDestPath = CLIUtils.resolveCachePackageDir(p); | ||
|
||
if (fs.existsSync(projectDestPath)) continue; | ||
|
||
fs.copySync(projectSrcPath, projectDestPath, { | ||
recursive: true, | ||
filter: (src, dest) => { | ||
const filtered = ['node_modules', 'dist', 'tmp'].every( | ||
(pattern) => !src.includes(pattern) | ||
); | ||
public static pre() {} | ||
|
||
return filtered; | ||
}, | ||
}); | ||
} | ||
} | ||
public static post() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters