WIP
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": ["oclif", "oclif-typescript", "prettier"]
|
||||
}
|
||||
+1
-1
@@ -17,5 +17,5 @@ pnpm-lock.yaml
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
|
||||
~~*
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
"@oclif/prettier-config"
|
||||
+7
-1
@@ -1,5 +1,11 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import {execute} from '@oclif/core'
|
||||
|
||||
|
||||
import {execute, settings} from '@oclif/core'
|
||||
// process.env.DEBUG=""
|
||||
|
||||
|
||||
settings.performanceEnabled = true
|
||||
|
||||
await execute({dir: import.meta.url})
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// eslint.config.js
|
||||
const prettierConfig = require("./prettier.config.js");
|
||||
|
||||
module.exports = {
|
||||
extends: ["oclif", "oclif-typescript", "prettier"],
|
||||
// Ignore specific folders to avoid unnecessary linting
|
||||
ignores: ["node_modules", "dist", "build"],
|
||||
// Specify the files to apply ESLint to
|
||||
files: ["*.js", "*.jsx", "*.ts", "*.tsx"],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2021,
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: {
|
||||
prettier: require("eslint-plugin-prettier"),
|
||||
},
|
||||
rules: {
|
||||
...require("eslint-config-prettier").rules, // Disable conflicting ESLint rules
|
||||
"prettier/prettier": ["warn", prettierConfig], // Use Prettier as a rule
|
||||
"no-restricted-syntax": "off",
|
||||
"padding-line-between-statements": [
|
||||
"error",
|
||||
{
|
||||
blankLine: "always",
|
||||
prev: "block",
|
||||
next: "*",
|
||||
},
|
||||
{
|
||||
blankLine: "always",
|
||||
prev: "block-like",
|
||||
next: "*",
|
||||
},
|
||||
],
|
||||
},
|
||||
// Set environments globally
|
||||
languageOptions: {
|
||||
globals: {
|
||||
browser: true,
|
||||
node: true,
|
||||
es2021: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
import { jjConfigs } from "@src/index";
|
||||
import path from "path";
|
||||
import fs from 'fs-extra';
|
||||
import inquirer from "inquirer";
|
||||
import * as YAML from "js-yaml"
|
||||
import { _ } from "lodash";
|
||||
|
||||
export const srmFileName = 'package.json'
|
||||
|
||||
export const srmFilePath = path.resolve(srmFileName);
|
||||
|
||||
|
||||
export const jjEnsure = async (opts) => {
|
||||
jjConfigs.modulePath = path.resolve(__dirname, "../")
|
||||
jjConfigs.tmpDir = `${jjConfigs.modulePath}/~~tmp`
|
||||
jjConfigs.configSaveFilePath = `${jjConfigs.tmpDir}/configSaveFilePath.txt`
|
||||
if (!fs.existsSync(jjConfigs.tmpDir)) {
|
||||
fs.mkdirSync(jjConfigs.tmpDir, { recursive: true })
|
||||
}
|
||||
|
||||
if (!fs.existsSync(jjConfigs.configSaveFilePath)) {
|
||||
|
||||
const answer: any = await inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'jjYamlPath',
|
||||
message: 'Please provide jj.yaml file absolute path',
|
||||
},
|
||||
])
|
||||
if (!fs.existsSync(answer.jjYamlPath)) {
|
||||
opts.context.error(`can not find ${answer.jjYamlPath}`)
|
||||
}
|
||||
|
||||
const jjYamlRawContent = await fs.readFile(answer.jjYamlPath, "utf8")
|
||||
const jjYamlObj: any = YAML.load(jjYamlRawContent)
|
||||
if (_.isEmpty(jjYamlObj?.environments || {})) {
|
||||
opts.context.error(`Wrong ${answer.jjYamlPath} file`)
|
||||
}
|
||||
|
||||
jjConfigs.jjYamlObj = jjYamlObj
|
||||
|
||||
await fs.writeFile(jjConfigs.configSaveFilePath, answer.jjYamlPath, "utf8")
|
||||
|
||||
} else {
|
||||
jjConfigs.jjYamlPath = await fs.readFile(jjConfigs.configSaveFilePath, "utf8")
|
||||
const jjYamlRawContent = await fs.readFile(jjConfigs.jjYamlPath, "utf8")
|
||||
const jjYamlObj: any = YAML.load(jjYamlRawContent)
|
||||
if (_.isEmpty(jjYamlObj?.environments || {})) {
|
||||
opts.context.error(`Wrong ${jjConfigs.jjYamlPath} file`)
|
||||
}
|
||||
jjConfigs.jjYamlObj = jjYamlObj
|
||||
}
|
||||
|
||||
}
|
||||
+12
-6
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jj-command-line",
|
||||
"description": "jj cli",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.7",
|
||||
"author": "Jason Jafari",
|
||||
"bin": {
|
||||
"jj": "./bin/run.ts"
|
||||
@@ -20,6 +20,7 @@
|
||||
"@oclif/plugin-warn-if-update-available": "^3.1.21",
|
||||
"@oclif/plugin-which": "^3.2.17",
|
||||
"fs-extra": "^11.2.0",
|
||||
"inquirer": "^12.0.1",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -37,7 +38,7 @@
|
||||
"oclif": "^4",
|
||||
"shx": "^0.3.3",
|
||||
"ts-node": "^10",
|
||||
"typescript": "^5"
|
||||
"typescript": "^5.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
@@ -53,7 +54,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "src/index.ts",
|
||||
"type": "module",
|
||||
"type": "commonjs",
|
||||
"oclif": {
|
||||
"bin": "jj",
|
||||
"dirname": "jj",
|
||||
@@ -74,9 +75,11 @@
|
||||
"theme": "theme.json",
|
||||
"hooks": {
|
||||
"prerun": [
|
||||
"./src/hooks/postrun/customPostRun.ts"
|
||||
"./src/hooks/prerun/customPreRun.ts"
|
||||
],
|
||||
"postrun": "./src/hooks/prerun/customPreRun.ts"
|
||||
"postrun": [
|
||||
"./src/hooks/postrun/customPostRun.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"repository": "https://github.com/jafarijason/jj/jj",
|
||||
@@ -86,5 +89,8 @@
|
||||
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
||||
"pre-publish": "git add . && git push --follow-tags"
|
||||
},
|
||||
"types": "dist/index.d.ts"
|
||||
"alias": {
|
||||
"@helpers/*": "./helpers/$1",
|
||||
"@src/*": "./src/$1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// "@oclif/prettier-config"
|
||||
|
||||
const baseConfig = require("@oclif/prettier-config");
|
||||
|
||||
module.exports = {
|
||||
...baseConfig,
|
||||
arrowParens: "always",
|
||||
bracketSameLine: true,
|
||||
bracketSpacing: true,
|
||||
jsxSingleQuote: false,
|
||||
printWidth: 150,
|
||||
semi: true,
|
||||
singleAttributePerLine: false,
|
||||
singleQuote: false,
|
||||
trailingComma: "es5",
|
||||
tabWidth: 4,
|
||||
useTabs: false,
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.json"],
|
||||
options: {
|
||||
parser: "json",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["*.ts", "*.mts", "*.tsx"],
|
||||
options: {
|
||||
parser: "typescript",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import {Command} from '@oclif/core'
|
||||
import { jjConfigs } from '@src/index'
|
||||
|
||||
export default class World extends Command {
|
||||
static args = {}
|
||||
@@ -14,6 +15,9 @@ hello world! (./src/commands/hello/world.ts)
|
||||
static flags = {}
|
||||
|
||||
async run(): Promise<void> {
|
||||
console.log(jjConfigs)
|
||||
this.log('hello world! (./src/commands/hello/world.ts)')
|
||||
this.warn('warn')
|
||||
this.debug('jjjjjjj')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { Hook, Command } from '@oclif/core'
|
||||
import fs from 'fs-extra';
|
||||
import _ from 'lodash';
|
||||
import { jjEnsure } from '@helpers/jjEnsure';
|
||||
|
||||
|
||||
const hook: Hook<'prerun'> = async function (opts) {
|
||||
|
||||
|
||||
|
||||
await jjEnsure(opts)
|
||||
|
||||
|
||||
// srmVersion
|
||||
// console.log(opts.Command.flags)
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
export {run} from '@oclif/core'
|
||||
export const jjConfigs: any = {}
|
||||
|
||||
export { run } from '@oclif/core'
|
||||
|
||||
+19
-11
@@ -1,15 +1,23 @@
|
||||
{
|
||||
"ts-node": {
|
||||
"require": ["tsconfig-paths/register"]
|
||||
},
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"module": "Node16",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"target": "es2022",
|
||||
"moduleResolution": "node16"
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"ts-node": {
|
||||
"esm": true
|
||||
"module": "CommonJS",
|
||||
"baseUrl": ".",
|
||||
"target": "ES6",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
"@helpers/*": ["./helpers/*"],
|
||||
"@src/*": ["./src/*"],
|
||||
},
|
||||
"jsx": "react-jsx",
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": false,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user