-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use koffi instead of ffi-napi to support nodejs >= 18
ref: node-ffi-napi/node-ffi-napi#269 Notable changes summary: 1. Use [koffi] as node-ffi to support nodejs >= 18 2. Remove dependencies ffi-napi, ref-napi, ref-struct-di, ref-union-di 3. Easy structures initialization `<struct name>_Factory()` 4. Very easy structure/union definition 5. Auto create necessary struct/union when loading library from method def 6. Multiple Choice Parameters details: https://github.com/waitingsong/node-win32-api/CHANGES.v22.md
- Loading branch information
1 parent
21b8d17
commit 3e8f7b5
Showing
418 changed files
with
10,970 additions
and
8,737 deletions.
There are no files selected for viewing
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
# | ||
# 根据 commitmsg 以及 branch name 判断是否需要 commitlint | ||
# | ||
# Author: waiting | ||
# Date: 2023.07.21 | ||
# | ||
|
||
if [[ -z $NVM_DIR ]]; then | ||
if [[ -f $HOME/.nvm/nvm.sh ]]; then | ||
. $HOME/.nvm/nvm.sh | ||
fi | ||
fi | ||
|
||
branch=$( git branch | grep \* | cut -d ' ' -f2 ) | ||
# ./.githooks/init-repo/is-skip-commitlint.ts $1 "$branch" | ||
|
||
# code=$? | ||
code=0 | ||
#echo -e 'node exitCode:' $code | ||
|
||
if [[ -f ./node_modules/.bin/commitlint ]]; then | ||
if [[ $code = 0 ]] && [[ -d node_modules ]] ; then | ||
./node_modules/.bin/commitlint -e ./.git/COMMIT_EDITMSG | ||
fi | ||
fi | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env tsx | ||
/** | ||
* 搜索指定目录以 file.example 文件为基础生成不带后缀的文件为不带 .example 后缀的文件 | ||
*/ | ||
import { dirname, join, sep } from 'node:path' | ||
import { cp, mkdir, readdir } from 'node:fs/promises' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
// import { folderArr, globalConfigFileArr } from './init.config.js' | ||
import { genFileFromExample } from './init-example-file.js' | ||
|
||
|
||
const folderArr: string[] = [ | ||
'./', | ||
'.vscode', | ||
'.settings', | ||
'resource', | ||
'configs', | ||
'config', // egg | ||
'src/config', // midway | ||
] | ||
|
||
const globalConfigFileArr: string[] = [ | ||
'.vscode/tasks.json.example', | ||
'.vscode/launch.json.example', | ||
'.vscode/settings.json.example', | ||
'.vscode/ci.code-snippets.example', | ||
'.vscode/midway.code-snippets.example', | ||
'.vscode/promise.code-snippets.example', | ||
'./tsconfig.base.json', | ||
'./tsconfig.eslint.json', | ||
// './rollup.config.js', | ||
'./bin-hashbang.js', | ||
] | ||
|
||
const currentURL = import.meta.url | ||
const currentPath = fileURLToPath(currentURL) | ||
const currentDir = dirname(currentPath) | ||
const currentFileName = currentPath.split(sep).pop() | ||
const rootDir = join(currentDir, '..') | ||
console.log({ rootDir, currentFileName }) | ||
|
||
const pkgEntryName = 'packages' | ||
const pkgBase = join(rootDir, pkgEntryName) | ||
|
||
const files = await cpGlobalConfigsToPkgs(rootDir, globalConfigFileArr, pkgBase) | ||
console.log('Sync config:', files) | ||
|
||
const files2 = await genFileFromExample(rootDir, folderArr) | ||
console.info(`生成基础文件:${rootDir}`, files2) | ||
|
||
const dirs = await readdir(pkgBase) | ||
const arr: string[] = [] | ||
|
||
for (const name of dirs) { | ||
const pkgPath = join(pkgBase, name) | ||
const files3 = await genFileFromExample(pkgPath, folderArr) | ||
files3.forEach(file => arr.push(`${pkgEntryName}/${name}/${file}`)) | ||
console.info(`生成包文件:`, arr) | ||
} | ||
|
||
|
||
// --------------------------------------------- | ||
|
||
async function cpGlobalConfigsToPkgs( | ||
baseDir: string, | ||
configPaths: string[], | ||
pkgBase: string, | ||
): Promise<string[]> { | ||
|
||
const pkgs = await readdir(pkgBase) | ||
const ret: string[] = [] | ||
|
||
for (const pkg of pkgs) { | ||
for (const path of configPaths) { | ||
try { | ||
const dst = `${pkg}/${path}` | ||
const dstDir = dirname(join(pkgBase, dst)) | ||
await mkdir(dstDir, { recursive: true }) | ||
await cp( | ||
join(baseDir, path), | ||
join(pkgBase, dst), | ||
) | ||
ret.push(dst) | ||
} | ||
catch (ex: any) { | ||
console.log(ex.message) | ||
} | ||
} | ||
} | ||
|
||
return ret | ||
} | ||
|
||
/** | ||
* Generate random integer | ||
* | ||
* @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/random | ||
*/ | ||
export function genRandomInt(max: number): number { | ||
return Math.floor(Math.random() * Math.floor(max)) | ||
} |
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,102 @@ | ||
#!/usr/bin/env tsx | ||
/** | ||
* 搜索指定目录以 file.example 文件为基础生成不带后缀的文件为不带 .example 后缀的文件 | ||
*/ | ||
import { dirname, join, sep } from 'node:path' | ||
import { cp, mkdir, readdir } from 'node:fs/promises' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
// import { folderArr, globalConfigFileArr } from './init.config.js' | ||
import { genFileFromExample } from './init-example-file.js' | ||
|
||
|
||
const folderArr: string[] = [ | ||
'./', | ||
'.vscode', | ||
'.settings', | ||
'resource', | ||
'configs', | ||
'config', // egg | ||
'src/config', // midway | ||
] | ||
|
||
const globalConfigFileArr: string[] = [ | ||
'.vscode/tasks.json.example', | ||
'.vscode/launch.json.example', | ||
'.vscode/settings.json.example', | ||
'.vscode/ci.code-snippets.example', | ||
'.vscode/midway.code-snippets.example', | ||
'.vscode/promise.code-snippets.example', | ||
'./tsconfig.base.json', | ||
'./tsconfig.eslint.json', | ||
// './rollup.config.js', | ||
'./bin-hashbang.js', | ||
] | ||
|
||
const currentURL = import.meta.url | ||
const currentPath = fileURLToPath(currentURL) | ||
const currentDir = dirname(currentPath) | ||
const currentFileName = currentPath.split(sep).pop() | ||
const rootDir = join(currentDir, '..') | ||
console.log({ rootDir, currentFileName }) | ||
|
||
const pkgEntryName = 'packages' | ||
const pkgBase = join(rootDir, pkgEntryName) | ||
|
||
const files = await cpGlobalConfigsToPkgs(rootDir, globalConfigFileArr, pkgBase) | ||
console.log('Sync config:', files) | ||
|
||
const files2 = await genFileFromExample(rootDir, folderArr) | ||
console.info(`生成基础文件:${rootDir}`, files2) | ||
|
||
const dirs = await readdir(pkgBase) | ||
const arr: string[] = [] | ||
|
||
for (const name of dirs) { | ||
const pkgPath = join(pkgBase, name) | ||
const files3 = await genFileFromExample(pkgPath, folderArr) | ||
files3.forEach(file => arr.push(`${pkgEntryName}/${name}/${file}`)) | ||
console.info(`生成包文件:`, arr) | ||
} | ||
|
||
|
||
// --------------------------------------------- | ||
|
||
async function cpGlobalConfigsToPkgs( | ||
baseDir: string, | ||
configPaths: string[], | ||
pkgBase: string, | ||
): Promise<string[]> { | ||
|
||
const pkgs = await readdir(pkgBase) | ||
const ret: string[] = [] | ||
|
||
for (const pkg of pkgs) { | ||
for (const path of configPaths) { | ||
try { | ||
const dst = `${pkg}/${path}` | ||
const dstDir = dirname(join(pkgBase, dst)) | ||
await mkdir(dstDir, { recursive: true }) | ||
await cp( | ||
join(baseDir, path), | ||
join(pkgBase, dst), | ||
) | ||
ret.push(dst) | ||
} | ||
catch (ex: any) { | ||
console.log(ex.message) | ||
} | ||
} | ||
} | ||
|
||
return ret | ||
} | ||
|
||
/** | ||
* Generate random integer | ||
* | ||
* @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/random | ||
*/ | ||
export function genRandomInt(max: number): number { | ||
return Math.floor(Math.random() * Math.floor(max)) | ||
} |
34 changes: 23 additions & 11 deletions
34
.githooks/init-repo/init-example-file.ts → .githooks/init-example-file.ts
100644 → 100755
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
Oops, something went wrong.