Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
vagusX committed Jul 9, 2020
0 parents commit 1e00e3e
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
env:
browser: true
es2020: true
extends:
- standard
parserOptions:
ecmaVersion: 11
sourceType: module
rules: {}
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/

# downloaded extensions
extensions
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"semi": false,
"trailingComma": "none"
}
48 changes: 48 additions & 0 deletions config/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"extensions": {
"vscode-extensions": [
{
"name": "html",
"version": "1.0.0"
},
{
"name": "css",
"version": "1.0.0"
},
{
"name": "javascript",
"version": "1.0.0"
},
{
"name": "json",
"version": "1.0.0"
},
{
"name": "less",
"version": "1.0.0"
},
{
"name": "scss",
"version": "1.0.0"
},
{
"name": "markdown-basics",
"version": "1.0.0"
},
{
"name": "go",
"version": "1.0.0"
},
{
"name": "java",
"version": "1.0.0"
}
],
"kaitian": [
{
"name": "typescript-basics",
"version": "1.37.2-patch.1"
}
]
}
}
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "textmate-languages",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"download": "node scripts/update-extensions.js"
},
"repository": {
"type": "git",
"url": "[email protected]:kaitian/textmate-languages.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@ali/ide-extension-installer": "^1.0.5",
"bluebird": "^3.7.2",
"eslint": "^7.4.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"js-yaml": "^3.14.0",
"mkdirp": "^1.0.4",
"rimraf": "^3.0.2"
}
}
15 changes: 15 additions & 0 deletions scripts/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const yaml = require('js-yaml')
const fs = require('fs')
const os = require('os')
const path = require('path')

module.exports = () => {
// tricky to read kaitian
try {
const ymlPath = path.resolve(os.homedir(), '.ali-kaitian-cli/config.yml')
const doc = yaml.safeLoad(fs.readFileSync(ymlPath, 'utf8'))
return doc && doc.teamAccounts && doc.teamAccounts.kaitian
} catch (e) {
console.log(e)
}
}
55 changes: 55 additions & 0 deletions scripts/update-extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path')
const rimraf = require('rimraf')
const mkdirp = require('mkdirp')
const { ExtensionInstaller } = require('@ali/ide-extension-installer')
const Promise = require('bluebird')

const pkg = require('../package.json')
const account = require('./account')()

// 放置 kaitian extension 的目录
const targetDir = path.resolve(__dirname, '../extensions')

const extensionInstaller = new ExtensionInstaller({
accountId: account.accountId,
masterKey: account.masterKey,
frameworkVersion: pkg.version,
dist: targetDir,
ignoreIncreaseCount: true
})

// vscode extension 的 tar 包 oss 地址
const { extensions } = require(path.resolve(
__dirname,
'../config/extensions.json'
))

const downloadVscodeExtensions = async () => {
console.log('清空 extensions 目录:%s', targetDir)
rimraf.sync(targetDir)
mkdirp.sync(targetDir)

for (const publisher of Object.keys(extensions)) {
Promise.map(
extensions[publisher],
async (item) => {
const { name, version } = item
console.log('开始安装:%s', name)
await extensionInstaller.install({
publisher,
name,
version
})
},
{ concurrency: 3 }
)
}

console.log('安装完毕')
}

// 执行并捕捉异常
downloadVscodeExtensions().catch((e) => {
console.trace(e)
process.exit(128)
})

0 comments on commit 1e00e3e

Please sign in to comment.