Skip to content

Commit

Permalink
feat: support handle pkg-plugin-dev (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
luhc228 authored Feb 28, 2024
1 parent 564277f commit 8f49cce
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/create-pkg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.3.3

- feat: support handle pkg-plugin-dev

## 1.3.2

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/create-pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/create-pkg",
"version": "1.3.2",
"version": "1.3.3",
"description": "npm init @ice/pkg",
"type": "module",
"exports": "./lib/index.mjs",
Expand Down Expand Up @@ -36,6 +36,7 @@
"cac": "^6.7.12",
"consola": "^2.15.3",
"fs-extra": "^10.0.0",
"globby": "^14.0.1",
"ice-npm-utils": "^3.0.2",
"inquirer": "^8.2.1",
"os-locale": "^6.0.2",
Expand Down
19 changes: 19 additions & 0 deletions packages/create-pkg/src/index.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node

import { fileURLToPath } from 'url';
import { checkAliInternal } from 'ice-npm-utils';
import { globby } from 'globby';
import consola from 'consola';
import { cac } from 'cac';
import fs from 'fs-extra';
Expand Down Expand Up @@ -55,6 +57,8 @@ interface CliOptions {

async function create(dirPath: string, dirname: string, options: CliOptions): Promise<void> {
const info = await getInfo();
const isInternal = await checkAliInternal();

await fs.ensureDir(dirPath);
const empty = await checkEmpty(dirPath);

Expand Down Expand Up @@ -85,6 +89,7 @@ async function create(dirPath: string, dirname: string, options: CliOptions): Pr
npmName,
// @ts-expect-error generateMaterial should support index signature.
workspace: options.workspace,
internal: isInternal,
},
materialTemplateDir: tempDir,
materialType: 'component',
Expand All @@ -97,6 +102,20 @@ async function create(dirPath: string, dirname: string, options: CliOptions): Pr
await removeFilesAndContent(dirPath);
}

if (isInternal) {
const docsDirectories = await globby('**/docs', {
cwd: dirPath,
onlyFiles: false,
});
await Promise.all(docsDirectories.map((doc) => fs.remove(path.join(dirPath, doc))));
} else {
const devDirectories = await globby('**/dev', {
cwd: dirPath,
onlyFiles: false,
});
await Promise.all(devDirectories.map((dev) => fs.remove(path.join(dirPath, dev))));
}

console.log();
console.log(info.initSuccess);
console.log();
Expand Down
52 changes: 52 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8f49cce

Please sign in to comment.