Skip to content

Commit ae94b4f

Browse files
committed
feat: cli move to packages
1 parent d65526a commit ae94b4f

68 files changed

Lines changed: 2630 additions & 41 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.cjs

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// @ts-check
2+
const { builtinModules } = require('node:module')
3+
const { defineConfig } = require('eslint-define-config')
4+
5+
module.exports = defineConfig({
6+
root: true,
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:n/recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:regexp/recommended',
12+
],
13+
ignorePatterns: ['packages/create-quarkc/template-**'],
14+
plugins: ['import', 'regexp'],
15+
parser: '@typescript-eslint/parser',
16+
parserOptions: {
17+
sourceType: 'module',
18+
ecmaVersion: 2021,
19+
},
20+
rules: {
21+
eqeqeq: ['warn', 'always', { null: 'never' }],
22+
'no-debugger': ['error'],
23+
'no-empty': ['warn', { allowEmptyCatch: true }],
24+
'no-process-exit': 'off',
25+
'no-useless-escape': 'off',
26+
'prefer-const': [
27+
'warn',
28+
{
29+
destructuring: 'all',
30+
},
31+
],
32+
33+
'n/no-process-exit': 'off',
34+
'n/no-missing-import': 'off',
35+
'n/no-missing-require': [
36+
'error',
37+
{
38+
// for try-catching yarn pnp
39+
allowModules: ['pnpapi', 'quarkc'],
40+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
41+
},
42+
],
43+
'n/no-extraneous-import': [
44+
'error',
45+
{
46+
allowModules: ['quarkc', 'less', 'sass', 'unbuild'],
47+
},
48+
],
49+
'n/no-extraneous-require': [
50+
'error',
51+
{
52+
allowModules: ['vite'],
53+
},
54+
],
55+
'n/no-deprecated-api': 'off',
56+
'n/no-unpublished-import': 'off',
57+
'n/no-unpublished-require': 'off',
58+
'n/no-unsupported-features/es-syntax': 'off',
59+
60+
'@typescript-eslint/ban-ts-comment': 'error',
61+
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
62+
'@typescript-eslint/explicit-module-boundary-types': [
63+
'error',
64+
{ allowArgumentsExplicitlyTypedAsAny: true },
65+
],
66+
'@typescript-eslint/no-empty-function': [
67+
'error',
68+
{ allow: ['arrowFunctions'] },
69+
],
70+
'@typescript-eslint/no-empty-interface': 'off',
71+
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
72+
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
73+
'@typescript-eslint/no-inferrable-types': 'off',
74+
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
75+
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
76+
'@typescript-eslint/no-var-requires': 'off',
77+
'@typescript-eslint/consistent-type-imports': [
78+
'error',
79+
{ prefer: 'type-imports' },
80+
],
81+
82+
'import/no-nodejs-modules': [
83+
'error',
84+
{ allow: builtinModules.map((mod) => `node:${mod}`) },
85+
],
86+
'import/no-duplicates': 'error',
87+
'import/order': 'error',
88+
'sort-imports': [
89+
'error',
90+
{
91+
ignoreCase: false,
92+
ignoreDeclarationSort: true,
93+
ignoreMemberSort: false,
94+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
95+
allowSeparatedGroups: false,
96+
},
97+
],
98+
99+
'regexp/no-contradiction-with-assertion': 'error',
100+
},
101+
overrides: [
102+
{
103+
files: ['packages/**'],
104+
excludedFiles: '**/__tests__/**',
105+
rules: {
106+
'no-restricted-globals': [
107+
'error',
108+
'require',
109+
'__dirname',
110+
'__filename',
111+
],
112+
},
113+
},
114+
{
115+
files: ['packages/create-quarkc/template-*/**', '**/build.config.ts'],
116+
rules: {
117+
'no-undef': 'off',
118+
'n/no-missing-import': 'off',
119+
'@typescript-eslint/explicit-module-boundary-types': 'off',
120+
},
121+
},
122+
{
123+
files: ['*.js', '*.mjs', '*.cjs'],
124+
rules: {
125+
'@typescript-eslint/explicit-module-boundary-types': 'off',
126+
},
127+
},
128+
{
129+
files: ['*.d.ts'],
130+
rules: {
131+
'@typescript-eslint/triple-slash-reference': 'off',
132+
},
133+
},
134+
],
135+
reportUnusedDisableDirectives: true,
136+
})

.eslintrc.json

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/create-quarkc/package.json'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: '16'
21+
registry-url: https://registry.npmjs.org/
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v2
25+
with:
26+
version: 7
27+
run_install: false
28+
29+
# Use cache to reduce installation time
30+
- name: Get pnpm store directory
31+
id: pnpm-cache
32+
shell: bash
33+
run: |
34+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
35+
36+
- uses: actions/cache@v3
37+
name: Setup pnpm cache
38+
with:
39+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
44+
- name: Install dependencies
45+
run: pnpm install
46+
47+
- name: Build
48+
run: pnpm run build
49+
50+
- name: publish
51+
working-directory: 'packages/create-quarkc'
52+
env:
53+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
54+
run: npm publish
55+
56+
# 使用 tyankatsu0105/read-package-version-actions@v1 工具来读取对应的package.json 数据
57+
- name: Read package.json
58+
uses: tyankatsu0105/read-package-version-actions@v1
59+
with:
60+
path: './packages/create-quarkc'
61+
id: package-version
62+
63+
# # 生成 Changelog
64+
# - name: Changelog
65+
# run: pnpm run changlog
66+
67+
# 提交 Tag
68+
- name: create git tag
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GIT_ACTION }}
71+
run: |
72+
git config --local user.email "sanqi_med@163.com"
73+
git config --local user.name "Sanqi"
74+
git tag v${{ steps.package-version.outputs.version }}
75+
git push origin v${{ steps.package-version.outputs.version }}
76+
77+
# 下面主要是创建 github 的release
78+
# 关于创建 release 的更多参数,可以查看 actions/create-release@v1
79+
- name: Create Release for Tag
80+
id: release_tag
81+
uses: actions/create-release@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GIT_ACTION }} # 这块需要用到 github的token,因为需要对分之进行代码推送
84+
with:
85+
tag_name: v${{ steps.package-version.outputs.version }}
86+
release_name: Release v${{ steps.package-version.outputs.version }}
87+
prerelease: false # 是否为预发布版本
88+
body: |
89+
请点击查看 [更新日志](https://github.com/hellof2e/quark-core/blob/main/packages/core/CHANGELOG.md).

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77
"scripts": {
88
"dev": "pnpm run -C demo dev",
99
"codeformat": "prettier --write *",
10-
"prepare": "husky install",
11-
"build": "pnpm run -C packages/core build",
12-
"changlog": "pnpm run -C packages/core changelog"
10+
"build": "pnpm -r --filter='./packages/create-quarkc' run build",
11+
"changlog": "pnpm run -C packages/core changelog",
12+
"quarkcore:build": "pnpm run -C packages/core build"
1313
},
1414
"devDependencies": {
1515
"@commitlint/cli": "^17.0.3",
1616
"@typescript-eslint/eslint-plugin": "^5.59.9",
1717
"@typescript-eslint/parser": "^5.59.9",
1818
"eslint": "^7.23.2",
19-
"husky": "^8.0.1",
19+
"eslint-define-config": "^1.21.0",
2020
"lint-staged": "^10.5.4",
2121
"prettier": "^2.0.0",
2222
"rimraf": "^3.0.2",
2323
"shelljs": "^0.8.5",
2424
"typescript": "^5.0.2",
2525
"less": "^4.1.3",
2626
"postcss": "^8.4.24",
27+
"unbuild": "^1.2.1",
2728
"vite": "^4.1.0"
2829
},
2930
"packageManager": "pnpm@8.6.2",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
entries: ['src/index'],
5+
clean: true,
6+
rollup: {
7+
inlineDependencies: true,
8+
esbuild: {
9+
minify: true,
10+
},
11+
},
12+
alias: {
13+
// we can always use non-transpiled code since we support 14.18.0+
14+
prompts: 'prompts/lib/index.js',
15+
},
16+
})

packages/create-quarkc/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
import './dist/index.mjs'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "create-quarkc",
3+
"version": "1.3.1",
4+
"type": "module",
5+
"license": "MIT",
6+
"author": "xsf0105",
7+
"bin": {
8+
"create-quarkc": "index.js",
9+
"cva": "index.js"
10+
},
11+
"files": [
12+
"index.js",
13+
"template-*",
14+
"dist"
15+
],
16+
"scripts": {
17+
"dev": "unbuild --stub",
18+
"build": "unbuild",
19+
"typecheck": "tsc --noEmit",
20+
"prepublishOnly": "npm run build"
21+
},
22+
"engines": {
23+
"node": "^14.18.0 || >=16.0.0"
24+
},
25+
"repository": "https://github.com/hellof2e/quark-cli",
26+
"devDependencies": {
27+
"@types/cross-spawn": "^6.0.2",
28+
"@types/minimist": "^1.2.2",
29+
"@types/prompts": "^2.4.4",
30+
"cross-spawn": "^7.0.3",
31+
"kolorist": "^1.8.0",
32+
"minimist": "^1.2.8",
33+
"prompts": "^2.4.2"
34+
}
35+
}

0 commit comments

Comments
 (0)