Skip to content

Commit

Permalink
feat: upgrade compilation, deps, ci config.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016 committed Nov 10, 2023
1 parent 0e4dd77 commit a01885a
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 101 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/run-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: run ci for fibjs

on:
push:
branches:
- 'ci/**'
- 'ci-**'
- 'releases/**'
- 'feat/**'
- 'bugfix/**'
- 'dev'
- 'master'
- 'test_ci'
tags:
- v*.*.*
- test_github_actions_*
pull_request:
branches:
- 'dev'

jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macos-10.15]
version: [0.31.0, 0.32.0, 0.33.0, 0.34.0, 0.35.0, 0.36.0]
arch: [amd64, i386]
exclude:
- os: windows-2019
arch: i386
- os: macos-10.15
arch: i386

steps:
- name: Check out Git repository
uses: actions/checkout@v2
with:
submodules: 'recursive'

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Set Env Variables
id: set-env-vars
shell: bash
run: |
bash .github/workflows/set-env-vars.sh
env:
ARCH: ${{ matrix.arch }}
OS: ${{ matrix.os }}

- name: Install FIBJS
shell: bash
run: |
mkdir -p ./node_modules/.bin;
rm -rf ./node_modules/.bin/fibjs;
if [[ "$RUNNER_OS" == "Linux" ]]; then
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}.xz" -o ./node_modules/.bin/fibjs.xz;
xz -d ./node_modules/.bin/fibjs.xz;
chmod a+x ./node_modules/.bin/fibjs;
elif [[ "$RUNNER_OS" == "macOS" ]]; then
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}" -o ./node_modules/.bin/fibjs;
chmod a+x ./node_modules/.bin/fibjs;
else
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}.exe" -o ./node_modules/.bin/fibjs.exe;
fi
env:
FIBJS_OS: ${{ steps.set-env-vars.outputs.FIBJS_OS }}
FIBJS_ARCH: ${{ steps.set-env-vars.outputs.FIBJS_ARCH }}
FIBJS_VERSION: ${{ matrix.version }}

- name: Run CI
shell: bash
run: |
if [[ -f ".github/workflows/run-ci.sh" ]]; then
bash .github/workflows/run-ci.sh;
else
npm install;
npm run ci;
fi
env:
FIBJS_OS: ${{ steps.set-env-vars.outputs.FIBJS_OS }}
GIT_BRANCH: ${{ steps.set-env-vars.outputs.GIT_BRANCH }}
RELEASE_TAG: ${{ steps.set-env-vars.outputs.RELEASE_TAG }}
GIT_TAG: ${{ steps.set-env-vars.outputs.GIT_TAG }}
56 changes: 56 additions & 0 deletions .github/workflows/set-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export GIT_BRANCH=${GITHUB_REF#refs/heads/}
echo "::set-output name=GIT_BRANCH::$GIT_BRANCH"
export GIT_TAG=$(git tag | grep $(git describe --tags HEAD))
echo "::set-output name=GIT_TAG::$GIT_TAG"
export GIT_COMMIT_HEAD_MSG=$(git log --format=%b -1)
echo "::set-output name=GIT_COMMIT_HEAD_MSG::$GIT_COMMIT_HEAD_MSG"
export GIT_COMMIT_SHORTCUTS=$(git log --format=%h -1)
echo "::set-output name=GIT_COMMIT_SHORTCUTS::$GIT_COMMIT_SHORTCUTS"
export GIT_COMMIT_TIME=$(git show -s --format="%cd" --date=format:%Y%m%d%H%M%S HEAD)
echo "::set-output name=GIT_COMMIT_TIME::$GIT_COMMIT_TIME"

if [[ "$GIT_TAG" =~ ^v?[012]\.[0-9]+\.[0-9]+$ ]]; then
export IS_GIT_TAG_MATCH_SEMVER="true"
echo "::set-output name=IS_GIT_TAG_MATCH_SEMVER::$IS_GIT_TAG_MATCH_SEMVER"
fi

if [ -z "$GIT_TAG" ]; then
export RELEASE_TAG="$GIT_COMMIT_TIME-$GIT_COMMIT_SHORTCUTS";
else
export RELEASE_TAG="$GIT_TAG";
fi
if [ -z "$IS_GIT_TAG_MATCH_SEMVER" ]; then
SUFFIX=${GIT_BRANCH//\//'-'}
RELEASE_TAG="$RELEASE_TAG-$SUFFIX"
fi
echo "::set-output name=RELEASE_TAG::$RELEASE_TAG";

case "${RUNNER_OS}" in
Windows)
export FIBJS_OS=windows
;;
macOS)
export FIBJS_OS=darwin
;;
Linux)
export FIBJS_OS=linux
;;
*)
echo "unsupported RUNNER_OS ${RUNNER_OS}";
exit 1
;;
esac
echo "::set-output name=FIBJS_OS::$FIBJS_OS";

case "${ARCH}" in
i386)
export FIBJS_ARCH=x86
;;
amd64)
export FIBJS_ARCH=x64
;;
*)
export FIBJS_ARCH=$ARCH
;;
esac
echo "::set-output name=FIBJS_ARCH::$FIBJS_ARCH";
70 changes: 0 additions & 70 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .typifyrc.json

This file was deleted.

4 changes: 0 additions & 4 deletions @types/index.d.ts

This file was deleted.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "builtin-modules of fibjs",
"main": "./lib/index.js",
"scripts": {
"build": "fib-typify src -c .typifyrc.json -o lib",
"build": "rimraf ./lib ./typings && ftsc ./src/* --outDir ./lib",
"test": "fibjs test/index.js",
"ci": "npm run build && npm run test",
"prepublishOnly": "npm run build"
Expand All @@ -24,20 +24,20 @@
},
"homepage": "https://github.com/fibjs-modules/builtin-modules#readme",
"devDependencies": {
"@fibjs/ci": "^2.1.0",
"@types/fibjs": "^0.26.3",
"fib-typify": "^0.3.1"
"@fibjs/ci": "^2.6.0",
"@fibjs/types": "^0.36.1",
"fib-typify": "^0.11.5",
"rimraf": "^5.0.5"
},
"ci": {
"type": "travis",
"type": "actions",
"version": [
"0.21.0",
"0.22.0",
"0.23.0",
"0.24.0",
"0.25.0",
"0.26.0",
"0.26.1"
"0.31.0",
"0.32.0",
"0.33.0",
"0.34.0",
"0.35.0",
"0.36.0"
]
},
"engines": {
Expand Down
26 changes: 21 additions & 5 deletions src/builtin-modules.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@fibjs/types" />

import util = require('util')

const builtInfo: any = util.buildInfo()
Expand All @@ -13,14 +15,28 @@ const builtInModulesVersionMap = {
"0.23.0": [ "zmq", "zlib", "zip", "xml", "ws", "vm", "uuid", "util", "url", "tty", "timers", "test", "string_decoder", /* "tls", */ "ssl", "querystring", "punycode", "profiler", "process", "path", "os", "net", "mq", "json", "io", "iconv", /* "https", */ "http", "hex", "hash", "gd", "fs", "events", "encoding", "dns", "dgram", "db", "crypto", "coroutine", "buffer", "bson", "base64vlq", "base64", "base32", "assert" ],
"0.22.0": [ "zmq", "zlib", "zip", "xml", "ws", "vm", "uuid", "util", "url", "tty", "timers", "test", "string_decoder", /* "tls", */ "ssl", "querystring", "punycode", "profiler", "process", "path", "os", "net", "mq", "json", "io", "iconv", /* "https", */ "http", "hex", "hash", "gd", "fs", "events", "encoding", "dns", "dgram", "db", "crypto", "coroutine", "buffer", "bson", "base64vlq", "base64", "base32", "assert" ],
"0.21.0": [ "zmq", "zlib", "zip", "xml", "ws", "vm", "uuid", "util", "url", "tty", "timers", "test", "string_decoder", /* "tls", */ "ssl", "querystring", "punycode", "profiler", "process", "path", "os", "net", "mq", "json", "io", "iconv", /* "https", */ "http", "hex", "hash", "gd", "fs", "events", "encoding", "dns", /* "dgram", */ "db", "crypto", "coroutine", "buffer", "bson", "base64vlq", "base64", "base32", "assert" ]
} as Record<string, string[]>

// since 0.37.0, builtInfo.fibjsBuiltins, builtInfo.builtins is available
let internalModuleNameList: string[] | null = null;

if (Array.isArray(builtInfo.builtins) && builtInfo.builtins.length) {
internalModuleNameList = builtInfo.builtins
} else if (Array.isArray(builtInfo.fibjsBuiltins) && builtInfo.fibjsBuiltins.length) {
internalModuleNameList = builtInfo.fibjsBuiltins
} else if (Array.isArray(builtInfo.modules) && builtInfo.modules.length) {
internalModuleNameList = builtInfo.modules
}

const internalModuleNameList = builtInfo.modules && builtInfo.modules.length ? builtInfo.modules : null
type ModuleList = string[] & {
default: ModuleList;
}

const moduleList =
const moduleList = (
internalModuleNameList ?
internalModuleNameList :
(fibjsVersion && builtInModulesVersionMap[fibjsVersion] ? builtInModulesVersionMap[fibjsVersion] : builtInModulesVersionMap['default']);
(fibjsVersion && builtInModulesVersionMap[fibjsVersion] ? builtInModulesVersionMap[fibjsVersion] : builtInModulesVersionMap['default'])) as ModuleList;

moduleList.default = moduleList

;(moduleList as any).default = moduleList
export = moduleList
export = moduleList;
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import builtInModules from './builtin-modules'
/// <reference types="@fibjs/types" />

export = builtInModules
import './util/get-builtin-module-hash';
import './util/is-builtin-module';

import builtInModules = require('./builtin-modules')

export = builtInModules;

// export * from './util/get-builtin-module-hash';
// export * from './util/is-builtin-module';
4 changes: 2 additions & 2 deletions src/util/get-builtin-module-hash.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const builtInModules = require('../../')
import builtInModules from '../builtin-modules'

export = function getBuiltInModuleHash () {
const hash = {}
const hash = {} as Record<string, string[]>
builtInModules.forEach(name => hash[name] = require(name))
return hash
}
2 changes: 1 addition & 1 deletion src/util/is-builtin-module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const builtInModules = require('../../')
import builtInModules from '../builtin-modules'

export = function isBuiltInModule (moduleName: string) {
return builtInModules.includes(moduleName)
Expand Down
32 changes: 32 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"noImplicitAny": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"inlineSourceMap": false,
"allowJs": true,
"lib": [
"es6",
"es2015",
"es2016"
],
"declaration": true,
"declarationDir": "typings",
"types": [
"@fibjs/types"
],
"typeRoots": [
"typings/index.d.ts"
]
},
"include": [
"src/**/*",
"src/util/is-builtin-module.ts"
],
"exclude": [
"src/**/*.js",
"test/**/*"
]
}

0 comments on commit a01885a

Please sign in to comment.