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/sdks
|
||||||
!.yarn/versions
|
!.yarn/versions
|
||||||
|
|
||||||
|
~~*
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"@oclif/prettier-config"
|
|
||||||
+7
-1
@@ -1,5 +1,11 @@
|
|||||||
#!/usr/bin/env bun
|
#!/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})
|
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",
|
"name": "jj-command-line",
|
||||||
"description": "jj cli",
|
"description": "jj cli",
|
||||||
"version": "0.0.5",
|
"version": "0.0.7",
|
||||||
"author": "Jason Jafari",
|
"author": "Jason Jafari",
|
||||||
"bin": {
|
"bin": {
|
||||||
"jj": "./bin/run.ts"
|
"jj": "./bin/run.ts"
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"@oclif/plugin-warn-if-update-available": "^3.1.21",
|
"@oclif/plugin-warn-if-update-available": "^3.1.21",
|
||||||
"@oclif/plugin-which": "^3.2.17",
|
"@oclif/plugin-which": "^3.2.17",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
|
"inquirer": "^12.0.1",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -37,7 +38,7 @@
|
|||||||
"oclif": "^4",
|
"oclif": "^4",
|
||||||
"shx": "^0.3.3",
|
"shx": "^0.3.3",
|
||||||
"ts-node": "^10",
|
"ts-node": "^10",
|
||||||
"typescript": "^5"
|
"typescript": "^5.6.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
@@ -53,7 +54,7 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"type": "module",
|
"type": "commonjs",
|
||||||
"oclif": {
|
"oclif": {
|
||||||
"bin": "jj",
|
"bin": "jj",
|
||||||
"dirname": "jj",
|
"dirname": "jj",
|
||||||
@@ -74,9 +75,11 @@
|
|||||||
"theme": "theme.json",
|
"theme": "theme.json",
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"prerun": [
|
"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",
|
"repository": "https://github.com/jafarijason/jj/jj",
|
||||||
@@ -86,5 +89,8 @@
|
|||||||
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
||||||
"pre-publish": "git add . && git push --follow-tags"
|
"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 {Command} from '@oclif/core'
|
||||||
|
import { jjConfigs } from '@src/index'
|
||||||
|
|
||||||
export default class World extends Command {
|
export default class World extends Command {
|
||||||
static args = {}
|
static args = {}
|
||||||
@@ -14,6 +15,9 @@ hello world! (./src/commands/hello/world.ts)
|
|||||||
static flags = {}
|
static flags = {}
|
||||||
|
|
||||||
async run(): Promise<void> {
|
async run(): Promise<void> {
|
||||||
|
console.log(jjConfigs)
|
||||||
this.log('hello world! (./src/commands/hello/world.ts)')
|
this.log('hello world! (./src/commands/hello/world.ts)')
|
||||||
|
this.warn('warn')
|
||||||
|
this.debug('jjjjjjj')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import { Hook, Command } from '@oclif/core'
|
import { Hook, Command } from '@oclif/core'
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { jjEnsure } from '@helpers/jjEnsure';
|
||||||
|
|
||||||
|
|
||||||
const hook: Hook<'prerun'> = async function (opts) {
|
const hook: Hook<'prerun'> = async function (opts) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await jjEnsure(opts)
|
||||||
|
|
||||||
|
|
||||||
// srmVersion
|
// srmVersion
|
||||||
// console.log(opts.Command.flags)
|
// console.log(opts.Command.flags)
|
||||||
// console.log(opts.Command.args)
|
// console.log(opts.Command.args)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
|
|
||||||
|
export const jjConfigs: any = {}
|
||||||
|
|
||||||
export { run } from '@oclif/core'
|
export { run } from '@oclif/core'
|
||||||
|
|||||||
+17
-9
@@ -1,15 +1,23 @@
|
|||||||
{
|
{
|
||||||
|
"ts-node": {
|
||||||
|
"require": ["tsconfig-paths/register"]
|
||||||
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"module": "Node16",
|
"module": "CommonJS",
|
||||||
"outDir": "dist",
|
"baseUrl": ".",
|
||||||
"rootDir": "src",
|
"target": "ES6",
|
||||||
"strict": true,
|
"moduleResolution": "node",
|
||||||
"target": "es2022",
|
"paths": {
|
||||||
"moduleResolution": "node16"
|
"@helpers/*": ["./helpers/*"],
|
||||||
|
"@src/*": ["./src/*"],
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*"],
|
"jsx": "react-jsx",
|
||||||
"ts-node": {
|
"resolveJsonModule": true,
|
||||||
"esm": true
|
"allowJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user