Skip to content

Commit

Permalink
wip: rework
Browse files Browse the repository at this point in the history
  • Loading branch information
vipzhicheng committed Mar 1, 2024
1 parent 5eea5e7 commit 8119f57
Show file tree
Hide file tree
Showing 59 changed files with 1,564 additions and 586 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
8 changes: 4 additions & 4 deletions packages/semo-plugin-script/.eslintrc.js → .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: './'
tsconfigRootDir: './',
},
rules: {
'@typescript-eslint/no-use-before-define': 'warn',
'@typescript-eslint/camelcase': ['error', { properties: 'never' }],
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/interface-name-prefix': 'never'
'@typescript-eslint/interface-name-prefix': 'never',
},
globals: {
process: true
}
process: true,
},
}
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "semo-mono",
"private": true,
"devDependencies": {
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"husky": "^9.0.11",
"lerna": "^8.1.2",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"stmux": "^1.8.7",
"vuepress": "^1.9.10"
},
Expand Down Expand Up @@ -34,5 +41,13 @@
"type": "git",
"url": "git@github.com:semojs/semo.git"
},
"dependencies": {}
"lint-staged": {
"*.{js,json}": [
"prettier --write"
],
"*.ts?(x)": [
"eslint --fix",
"prettier --parser=typescript --write"
]
}
}
1 change: 0 additions & 1 deletion packages/cli/.eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions packages/cli/.eslintrc.js

This file was deleted.

12 changes: 6 additions & 6 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node

import { Utils } from "@semo/core";
import path from "path";
import { Utils } from '@semo/core'
import path from 'path'

Utils.launchDispatcher({
packageDirectory: path.resolve(__dirname, ".."),
packageName: "@semo/cli",
scriptName: "semo",
packageDirectory: path.resolve(__dirname, '..'),
packageName: '@semo/cli',
scriptName: 'semo',
orgMode: true, // Means my package publish under npm orgnization scope
});
})
14 changes: 7 additions & 7 deletions packages/cli/src/commands/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ export const handler = async function (argv: any) {
'home-plugin-cache': path.resolve(
process.env.HOME,
'.' + scriptName,
'home-plugin-cache'
'home-plugin-cache',
),
'run-plugin-cache': path.resolve(
process.env.HOME,
'.' + scriptName,
'run-plugin-cache'
'run-plugin-cache',
),
'repl-package-cache': path.resolve(
process.env.HOME,
'.' + scriptName,
'repl-package-cache'
'repl-package-cache',
),
'repl-history': path.resolve(
process.env.HOME,
'.' + scriptName,
`.${scriptName}_repl_history`
`.${scriptName}_repl_history`,
),
'shell-history': path.resolve(
process.env.HOME,
'.' + scriptName,
`.${scriptName}_shell_history`
`.${scriptName}_shell_history`,
),
}

Expand All @@ -65,7 +65,7 @@ export const handler = async function (argv: any) {
// Limit only application can hook cleanup
const hookAppCleanup = await Utils.invokeHook<COMMON_OBJECT>(
`${scriptName}:cleanup`,
{ include: ['application'] }
{ include: ['application'] },
)
Object.keys(hookAppCleanup).forEach(key => {
let cachePath = hookAppCleanup[key]
Expand Down Expand Up @@ -116,7 +116,7 @@ export const handler = async function (argv: any) {
type: 'confirm',
name: 'confirmed',
message: Utils.warn(
`Confirm cleanup ${argv.type}? The operation can not be reversed!`
`Confirm cleanup ${argv.type}? The operation can not be reversed!`,
),
default: false,
},
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ export const aliases = 'cfg'
export const builder = function (yargs: any) {
yargs.option('global', {
alias: 'g',
describe: 'For reading/writing configs from/to global yml rc file, default is false'
describe:
'For reading/writing configs from/to global yml rc file, default is false',
})

const argv: any = Utils.getInternalCache().get('argv') || {}
const scriptName = argv.scriptName || 'semo'


Utils.extendSubCommand('config', scriptName, yargs, __dirname)
}

export const handler = async function (argv: any) {
}
export const handler = async function (argv: any) {}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/config/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const handler = async function (argv: any) {
? path.resolve(
process.env.HOME,
'.' + scriptName,
'.' + scriptName + 'rc.yml'
'.' + scriptName + 'rc.yml',
)
: ''
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/config/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const handler = async function (argv: any) {
? path.resolve(
process.env.HOME,
'.' + scriptName,
'.' + scriptName + 'rc.yml'
'.' + scriptName + 'rc.yml',
)
: ''
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/config/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const handler = async function (argv: any) {
? path.resolve(
process.env.HOME,
'.' + scriptName,
'.' + scriptName + 'rc.yml'
'.' + scriptName + 'rc.yml',
)
: ''
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/config/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const handler = async function (argv: any) {
? path.resolve(
process.env.HOME,
'.' + scriptName,
'.' + scriptName + 'rc.yml'
'.' + scriptName + 'rc.yml',
)
: ''
} else {
Expand All @@ -53,7 +53,7 @@ export const handler = async function (argv: any) {

if (!argv.global && !fs.existsSync(configPath)) {
Utils.error(
'Config file not found. you need to create config file manually to prove you know what you are doing.'
'Config file not found. you need to create config file manually to prove you know what you are doing.',
)
return
}
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const handler = async function (argv: any) {
if (argv.template) {
// Fetch repos from hook
let repos = await Utils.invokeHook<COMMON_OBJECT>(
`${scriptName}:create_project_template`
`${scriptName}:create_project_template`,
)
// Combine repos with config
Object.assign(repos, Utils.pluginConfig('create.template', {}))
Expand Down Expand Up @@ -130,7 +130,7 @@ export const handler = async function (argv: any) {
? argv.template
: Object.keys(repos).find(
key =>
repos[key].name && repos[key].name.indexOf(argv.template) > -1
repos[key].name && repos[key].name.indexOf(argv.template) > -1,
)
if (template && repos[template]) {
argv.repo = repos[template].repo || Utils.error('Repo not found')
Expand All @@ -144,10 +144,10 @@ export const handler = async function (argv: any) {
choices: Object.keys(repos).map(key => {
return {
name: `${Utils.color.green(
Utils.color.underline(repos[key].name)
Utils.color.underline(repos[key].name),
)} ${repos[key].tags
.map(tag =>
Utils.color.white(Utils.color.bgGreen(` ${tag} `))
Utils.color.white(Utils.color.bgGreen(` ${tag} `)),
)
.join(' ')}: ${Utils.color.white(repos[key].repo)}${
repos[key].description
Expand Down Expand Up @@ -194,7 +194,7 @@ export const handler = async function (argv: any) {
Utils.info(`Downloading from ${argv.repo}`)
try {
Utils.exec(
`git clone ${argv.repo} ${argv.name} --single-branch --depth=1 --branch ${argv.branch} --progress`
`git clone ${argv.repo} ${argv.name} --single-branch --depth=1 --branch ${argv.branch} --progress`,
)

Utils.success('Succeeded!')
Expand Down Expand Up @@ -253,7 +253,7 @@ export const handler = async function (argv: any) {
const initExtra = argv.yarn ? '--yarn' : ''
if (argv.name.indexOf(`${argv.scriptName}-plugin-`) === 0) {
Utils.exec(
`${argv.scriptName} init --exec-mode --plugin --force ${initExtra}`
`${argv.scriptName} init --exec-mode --plugin --force ${initExtra}`,
)
} else {
Utils.exec(`${argv.scriptName} init --exec-mode --force ${initExtra}`)
Expand All @@ -266,7 +266,7 @@ export const handler = async function (argv: any) {
} else if (process.platform === 'darwin') {
// change package.json attributes
Utils.exec(
`sed -i '' 's/"name": ".*"/"name": "${argv.name}"/' package.json`
`sed -i '' 's/"name": ".*"/"name": "${argv.name}"/' package.json`,
)
} else {
Utils.exec(`sed -i 's/"name": ".*"/"name": "${argv.name}"/' package.json`)
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const handler = function (argv) {
if (argv._.length === 1) {
Utils.info(
`The ${Utils.color.bold(
Utils.color.green('generate')
)} command is for generating code by code template.`
Utils.color.green('generate'),
)} command is for generating code by code template.`,
)
Utils.info(
`Use ${Utils.color.green('generate help')} to see supported generators.`
`Use ${Utils.color.green('generate help')} to see supported generators.`,
)
}
}
Loading

0 comments on commit 8119f57

Please sign in to comment.