-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rewrite publish and translate commands on extension api
- Loading branch information
Showing
49 changed files
with
6,786 additions
and
3,477 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
"url": "[email protected]:diplodoc-platform/cli.git" | ||
}, | ||
"bin": { | ||
"yfm": "build/index.js" | ||
"yfm": "build/index.js", | ||
"docs": "build/index.js" | ||
}, | ||
"main": "build/index.js", | ||
"files": [ | ||
|
@@ -27,8 +28,8 @@ | |
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", | ||
"lint:fix": "npm run lint -- --fix", | ||
"typecheck": "tsc --noEmit", | ||
"prepublishOnly": "npm run lint && npm run build", | ||
"git:head": "git checkout master && git pull" | ||
"test": "vitest", | ||
"prepublishOnly": "npm run lint && npm run build" | ||
}, | ||
"engines": { | ||
"node": ">=18.*" | ||
|
@@ -59,14 +60,16 @@ | |
"@types/json-stringify-safe": "^5.0.3", | ||
"@types/lodash": "4.14.195", | ||
"@types/mime-types": "2.1.4", | ||
"@types/node": "14.*", | ||
"@types/node": "^18.19.4", | ||
"@types/shelljs": "0.8.15", | ||
"@types/tar-stream": "^2.2.2", | ||
"@types/yargs": "17.0.24", | ||
"@vitest/coverage-v8": "^1.2.1", | ||
"ajv": "^8.11.0", | ||
"async": "^3.2.4", | ||
"axios": "^1.6.7", | ||
"chalk": "^4.1.2", | ||
"commander": "^12.0.0", | ||
"esbuild": "^0.20.0", | ||
"glob": "^8.0.3", | ||
"html-escaper": "^3.0.3", | ||
|
@@ -77,10 +80,14 @@ | |
"mime-types": "2.1.35", | ||
"minimatch": "^9.0.3", | ||
"node-html-parser": "^6.1.5", | ||
"normalize-path": "^3.0.0", | ||
"simple-git": "3.22.0", | ||
"slugify": "^1.6.5", | ||
"tapable": "^2.2.1", | ||
"tar-stream": "^3.1.4", | ||
"typescript": "^5.3.3", | ||
"typescript": "^5.4.5", | ||
"vite-tsconfig-paths": "^4.2.3", | ||
"vitest": "^1.1.3", | ||
"walk-sync": "^3.0.0" | ||
}, | ||
"husky": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const {resolve, join} = require('path'); | ||
const {readFileSync} = require('fs'); | ||
const {sync: glob} = require('glob'); | ||
const normalize = require('normalize-path'); | ||
|
||
function stripJsonComments(data) { | ||
return data.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => (g ? "" : m)); | ||
} | ||
|
||
module.exports = (relativeTsconfigPath = './tsconfig.json') => { | ||
const absTsconfigPath = resolve(process.cwd(), relativeTsconfigPath); | ||
|
||
const tsconfigData = stripJsonComments(readFileSync(absTsconfigPath, 'utf8')); | ||
|
||
const { compilerOptions } = JSON.parse(tsconfigData); | ||
|
||
const pathKeys = Object.keys(compilerOptions.paths); | ||
const re = new RegExp(`^(${pathKeys.join('|')})`); | ||
return { | ||
name: 'ts-paths', | ||
setup(build) { | ||
build.onResolve({ filter: re }, (args) => { | ||
const pathKey = pathKeys.find((pkey) => new RegExp(`^${pkey}`).test(args.path)); | ||
const [pathDir] = pathKey.split('*'); | ||
|
||
let file = args.path.replace(pathDir, ''); | ||
if (file === args.path) { // if importing from root of alias | ||
file = ''; | ||
} | ||
|
||
for (const dir of compilerOptions.paths[pathKey]) { | ||
const fileDir = normalize(resolve(process.cwd(), dir).replace('*', file)); | ||
|
||
let [matchedFile] = glob(`${fileDir}.+(ts|tsx|js|jsx)`); | ||
if (!matchedFile) { | ||
const [matchIndexFile] = glob(normalize(fileDir + '/index.+(ts|tsx|js|jsx)')); | ||
matchedFile = matchIndexFile; | ||
} | ||
|
||
if (matchedFile) { | ||
return { path: matchedFile }; | ||
} | ||
} | ||
|
||
return { path: args.path }; | ||
}); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export {build} from './build'; | ||
export {publish} from './publish'; | ||
export {translate} from './translate'; | ||
// export {publish} from './publish'; | ||
// export {translate} from './translate'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.