Skip to content

Commit

Permalink
feat: 增加与平台无关的构建命令脚本;修改 nmutils 包,支持 fs/promises
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Jul 26, 2021
1 parent 89c1ae7 commit 68615ff
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 5,715 deletions.
File renamed without changes.
5,781 changes: 75 additions & 5,706 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"init": "lerna run init",
"prepublishOnly": "npm run build && npm run copy-readme",
"init-start": "npm run init && npm run start",
"copy-readme": "npx copy-cli ./packages/less-api-framework/README.md ./README.md"
"copy-readme": "node scripts/copy-readme.js"
},
"keywords": [
"BaaS",
Expand All @@ -22,7 +22,7 @@
"less-api"
],
"devDependencies": {
"copy": "^0.3.2",
"fs-extra": "^9.1.0",
"husky": "^5.2.0"
}
}
16 changes: 16 additions & 0 deletions packages/less-api-framework/http/pkg.http
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ Content-Type: application/json
GET {{base_url}}/typing/package?packageName=crypto HTTP/1.1
Content-Type: application/json




### 获取 fs/promises

GET {{base_url}}/typing/package?packageName=fs/promises HTTP/1.1
Content-Type: application/json



### 获取 globals

GET {{base_url}}/typing/package?packageName=globals HTTP/1.1
Content-Type: application/json


24 changes: 24 additions & 0 deletions packages/less-api-framework/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ async function main() {
await createBuiltinFunctions()

accessor.close()

createCloudFunctionDeclarationPackage()
}

main()
Expand Down Expand Up @@ -198,4 +200,26 @@ async function createBuiltinFunctions() {
}

return true
}

// 在 node_modules 中创建 云函数 sdk 包:@, 这个包是为了云函数IDE 加载类型提示文件而创建的,不可发布
function createCloudFunctionDeclarationPackage() {
const source = path.resolve(__dirname, '../dist')
const target = path.resolve(__dirname, '../node_modules/@')

fse.ensureDirSync(target)
fse.copySync(source, target)

console.log(`copy success: ${source} => ${target}`)

const packageJson = `
{
"name": "@",
"version": "0.0.0"
}
`
const pkgJsonPath = path.join(target, 'package.json')
fse.writeFileSync(pkgJsonPath, packageJson)

console.log(`write success: ${pkgJsonPath}`)
}
3 changes: 0 additions & 3 deletions packages/less-api-framework/init/package.json

This file was deleted.

5 changes: 2 additions & 3 deletions packages/less-api-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"typings": "/dist/index.d.ts",
"private": "true",
"scripts": {
"start": "npm run create-pkg && node ./dist/index.js",
"build": "npx tsc -p tsconfig.json && npm run create-pkg",
"create-pkg": "cp -R dist node_modules/@ && cp ./init/package.json node_modules/@/package.json",
"start": "node ./dist/index.js",
"build": "npx tsc -p tsconfig.json",
"watch": "npx tsc -p tsconfig.json -w",
"init": "node init/index.js",
"prepublishOnly": "npm run build",
Expand Down
3 changes: 2 additions & 1 deletion packages/node-modules-utils/lib/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ export class NodePackageDeclarations {
'assert', 'crypto', 'child_process','path', 'process', 'readline', 'querystring', 'os',
'dns', 'domain', 'http', 'https', 'http2', 'module', 'net', 'tls', 'dgram',
'stream', 'tty', 'url', 'wasi', 'v8', 'vm', 'worker_threads', 'zlib',
'punycode', 'perf_hooks', 'fs', 'events', 'constants', 'console', 'cluster', 'buffer'
'punycode', 'perf_hooks', 'fs', 'events', 'constants', 'console', 'cluster', 'buffer',
'fs/promises', 'globals'
]


Expand Down
11 changes: 11 additions & 0 deletions scripts/copy-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fse = require('fs-extra')
const path = require('path')

async function main() {
const source = path.resolve(__dirname, '../packages/less-api-framework/README.md')
const target = path.resolve(__dirname, '../README.md')

fse.copyFileSync(source, target)
}

main()

0 comments on commit 68615ff

Please sign in to comment.