Compare commits

..

No commits in common. "master" and "7.3.0" have entirely different histories.

8 changed files with 152 additions and 360 deletions

View File

@ -1,47 +0,0 @@
name: Cpplint
defaults:
run:
shell: bash
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
eslint:
name: Cpplint
runs-on: ubuntu-20.04
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Install Modules
run: npm ci
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Cpplint
run: pip install cpplint
- name: Run Cpplint
run: |
node -e "require('.').cpcpplint()"
cpplint --recursive ./test-addon
cpplint --recursive ./include

View File

@ -1,18 +1,17 @@
set noparent set noparent
linelength=110 linelength=110
filter=-build/header_guard
filter=-build/include
filter=-build/include_order
filter=-build/include_what_you_use
filter=-build/namespaces
filter=-legal/copyright filter=-legal/copyright
filter=-readability/todo filter=-build/include_order
filter=-runtime/indentation_namespace filter=-build/include
filter=-build/header_guard
filter=-build/namespaces
filter=-build/include_what_you_use
filter=-whitespace/blank_line filter=-whitespace/blank_line
filter=-whitespace/braces
filter=-whitespace/comments filter=-whitespace/comments
filter=-whitespace/tab
filter=-whitespace/end_of_line filter=-whitespace/end_of_line
filter=-whitespace/indent filter=-whitespace/indent
filter=-whitespace/operators filter=-whitespace/operators
filter=-whitespace/parens filter=-whitespace/parens
filter=-whitespace/tab filter=-readability/todo
filter=-runtime/indentation_namespace

View File

@ -5,7 +5,6 @@ This is a part of [Node3D](https://github.com/node-3d) project.
[![NPM](https://badge.fury.io/js/addon-tools-raub.svg)](https://badge.fury.io/js/addon-tools-raub) [![NPM](https://badge.fury.io/js/addon-tools-raub.svg)](https://badge.fury.io/js/addon-tools-raub)
[![ESLint](https://github.com/node-3d/addon-tools-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/node-3d/addon-tools-raub/actions/workflows/eslint.yml) [![ESLint](https://github.com/node-3d/addon-tools-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/node-3d/addon-tools-raub/actions/workflows/eslint.yml)
[![Test](https://github.com/node-3d/addon-tools-raub/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/addon-tools-raub/actions/workflows/test.yml) [![Test](https://github.com/node-3d/addon-tools-raub/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/addon-tools-raub/actions/workflows/test.yml)
[![Cpplint](https://github.com/node-3d/addon-tools-raub/actions/workflows/cpplint.yml/badge.svg)](https://github.com/node-3d/addon-tools-raub/actions/workflows/cpplint.yml)
``` ```
npm i -s addon-tools-raub npm i -s addon-tools-raub

134
index.d.ts vendored
View File

@ -1,24 +1,20 @@
declare module "addon-tools-raub" { import type { Stats } from 'node:fs';
type Stats = import('node:fs').Stats; import type { Writable } from 'node:stream';
type Writable = import('node:stream').Writable;
type Readable = import('node:stream').Readable;
type WritableOptions = import('node:stream').WritableOptions;
declare module "addon-tools-raub" {
/** /**
* Get the internal paths for an addon * Get the internal paths for an addon
*
* Returns a set of platform dependent paths depending on the input dir * Returns a set of platform dependent paths depending on the input dir
*/ */
export const getPaths: (dir: string) => Readonly<{ export const getPaths: (dir: string) => Readonly<{
/** /**
* Path to binaries * Path to binaries
*
* Platform binary directory absolute path for this `dir` * Platform binary directory absolute path for this `dir`
*/ */
bin: string; bin: string;
/** /**
* Path to include * Path to include
*
* Include directory for this `dir` * Include directory for this `dir`
*/ */
include: string; include: string;
@ -39,7 +35,6 @@ declare module "addon-tools-raub" {
/** /**
* Get the include directories for **binding.gyp** * Get the include directories for **binding.gyp**
*
* Both 'addon-tools-raub' and 'node-addon-api' include paths. * Both 'addon-tools-raub' and 'node-addon-api' include paths.
* In binding.gyp: `'<!@(node -p "require(\'addon-tools-raub\').getInclude()")'` * In binding.gyp: `'<!@(node -p "require(\'addon-tools-raub\').getInclude()")'`
*/ */
@ -47,7 +42,6 @@ declare module "addon-tools-raub" {
/** /**
* Install binaries * Install binaries
*
* Downloads and unpacks the platform specific binary for the calling package. * Downloads and unpacks the platform specific binary for the calling package.
* To use it, create a new script for your package, which may as well be named * To use it, create a new script for your package, which may as well be named
* **install.js**, with the following content: * **install.js**, with the following content:
@ -74,7 +68,6 @@ declare module "addon-tools-raub" {
/** /**
* Copy binary * Copy binary
*
* Copies the addon binary from `src/build/Release` to the platform-specific folder. * Copies the addon binary from `src/build/Release` to the platform-specific folder.
* *
* ``` * ```
@ -90,7 +83,6 @@ declare module "addon-tools-raub" {
/** /**
* Packs binaries into GZIP * Packs binaries into GZIP
*
* Example of `actionPack` usage in **Github Actions**: * Example of `actionPack` usage in **Github Actions**:
* *
* ``` * ```
@ -108,7 +100,6 @@ declare module "addon-tools-raub" {
/** /**
* Download to memory * Download to memory
*
* Accepts an **URL**, and returns an in-memory file Buffer, * Accepts an **URL**, and returns an in-memory file Buffer,
* when the file is loaded. Use for small files, as the whole * when the file is loaded. Use for small files, as the whole
* file will be loaded into memory at once. * file will be loaded into memory at once.
@ -126,130 +117,24 @@ declare module "addon-tools-raub" {
/** /**
* (async) Read a file * (async) Read a file
*
* Reads a whole file to string, NOT A Buffer * Reads a whole file to string, NOT A Buffer
*/ */
type ComposeFnParam = (source: any) => void;
/** /**
* WritableBuffer * WritableBuffer
*
* A [Writable](https://nodejs.org/api/stream.html#stream_writable_streams) * A [Writable](https://nodejs.org/api/stream.html#stream_writable_streams)
* stream buffer, that is stored in-memory and can be fully * stream buffer, that is stored in-memory and can be fully
* obtained when writing was finished. It is equivalent to stream-writing * obtained when writing was finished. It is equivalent to stream-writing
* a temporary file and then reading it into a `Buffer`. * a temporary file and then reading it into a `Buffer`.
*/ */
export class WritableBuffer implements Writable { export class WritableBuffer extends Writable {
constructor(); constructor();
/** /**
* Get the downloaded data * Get the downloaded data
* Use `stream.get()` to obtain the data when writing was finished * Use `stream.get()` to obtain the data when writing was finished
*/ */
get(): Buffer; get(): Buffer;
// ----------- implements Writable
readonly writable: boolean;
readonly writableEnded: boolean;
readonly writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
readonly writableCorked: number;
destroyed: boolean;
readonly closed: boolean;
readonly errored: Error | null;
readonly writableNeedDrain: boolean;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
_writev?(
chunks: Array<{
chunk: any;
encoding: BufferEncoding;
}>,
callback: (error?: Error | null) => void,
): void;
_construct?(callback: (error?: Error | null) => void): void;
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
_final(callback: (error?: Error | null) => void): void;
write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
setDefaultEncoding(encoding: BufferEncoding): this;
end(cb?: () => void): this;
end(chunk: any, cb?: () => void): this;
end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
cork(): void;
uncork(): void;
destroy(error?: Error): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "drain", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "finish", listener: () => void): this;
addListener(event: "pipe", listener: (src: Readable) => void): this;
addListener(event: "unpipe", listener: (src: Readable) => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "close"): boolean;
emit(event: "drain"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "finish"): boolean;
emit(event: "pipe", src: Readable): boolean;
emit(event: "unpipe", src: Readable): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: "close", listener: () => void): this;
on(event: "drain", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "finish", listener: () => void): this;
on(event: "pipe", listener: (src: Readable) => void): this;
on(event: "unpipe", listener: (src: Readable) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "close", listener: () => void): this;
once(event: "drain", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "finish", listener: () => void): this;
once(event: "pipe", listener: (src: Readable) => void): this;
once(event: "unpipe", listener: (src: Readable) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "drain", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "finish", listener: () => void): this;
prependListener(event: "pipe", listener: (src: Readable) => void): this;
prependListener(event: "unpipe", listener: (src: Readable) => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "drain", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "finish", listener: () => void): this;
prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "drain", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: "finish", listener: () => void): this;
removeListener(event: "pipe", listener: (src: Readable) => void): this;
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
pipe<T extends NodeJS.WritableStream>(
destination: T,
options?: {
end?: boolean | undefined;
},
): T;
compose<T extends NodeJS.ReadableStream>(
stream: T | ComposeFnParam | Iterable<T> | AsyncIterable<T>,
options?: { signal: AbortSignal },
): T;
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(eventName: string | symbol): Function[];
rawListeners(eventName: string | symbol): Function[];
emit(eventName: string | symbol, ...args: any[]): boolean;
listenerCount(eventName: string | symbol, listener?: Function): number;
eventNames(): Array<string | symbol>;
} }
@ -297,42 +182,36 @@ declare module "addon-tools-raub" {
/** /**
* (async) Create a directory * (async) Create a directory
*
* Like `mkdir -p`, makes sure a directory exists * Like `mkdir -p`, makes sure a directory exists
*/ */
export const ensuredir: (dir: string) => Promise<void>; export const ensuredir: (dir: string) => Promise<void>;
/** /**
* (async) Copy a file * (async) Copy a file
*
* Copy a file, `dest` folder is created if needed * Copy a file, `dest` folder is created if needed
*/ */
export const copysafe: (src: string, dest: string) => Promise<void>; export const copysafe: (src: string, dest: string) => Promise<void>;
/** /**
* (async) Read a directory * (async) Read a directory
*
* Get file/folder names of the 1st level * Get file/folder names of the 1st level
*/ */
export const readdir: (src: string, dest: string) => Promise<ReadonlyArray<string>>; export const readdir: (src: string, dest: string) => Promise<ReadonlyArray<string>>;
/** /**
* (async) List subdirectories * (async) List subdirectories
*
* Get folder paths (concatenated with input) of the 1st level * Get folder paths (concatenated with input) of the 1st level
*/ */
export const subdirs: (name: string) => Promise<ReadonlyArray<string>>; export const subdirs: (name: string) => Promise<ReadonlyArray<string>>;
/** /**
* (async) List nested files * (async) List nested files
*
* Get file paths (concatenated with input) of the 1st level * Get file paths (concatenated with input) of the 1st level
*/ */
export const subfiles: (name: string) => Promise<ReadonlyArray<string>>; export const subfiles: (name: string) => Promise<ReadonlyArray<string>>;
/** /**
* (async) Get all nested files recursively * (async) Get all nested files recursively
*
* Folder paths are omitted by default. * Folder paths are omitted by default.
* Order is: shallow-to-deep, each subdirectory lists dirs-then-files. * Order is: shallow-to-deep, each subdirectory lists dirs-then-files.
*/ */
@ -340,21 +219,18 @@ declare module "addon-tools-raub" {
/** /**
* (async) Copy a directory * (async) Copy a directory
*
* Copy a folder with all the contained files * Copy a folder with all the contained files
*/ */
export const copyall: (src: string, dest: string) => Promise<void>; export const copyall: (src: string, dest: string) => Promise<void>;
/** /**
* (async) Remove a directory * (async) Remove a directory
*
* Like `rm -rf`, removes everything recursively * Like `rm -rf`, removes everything recursively
*/ */
export const rmdir: (name: string) => Promise<void>; export const rmdir: (name: string) => Promise<void>;
/** /**
* (async) Remove a file * (async) Remove a file
*
* Must be a file, not a folder. Just `fs.unlink`. * Must be a file, not a folder. Just `fs.unlink`.
*/ */
export const rm: (name: string) => Promise<void>; export const rm: (name: string) => Promise<void>;

11
package-lock.json generated
View File

@ -1,15 +1,14 @@
{ {
"name": "addon-tools-raub", "name": "addon-tools-raub",
"version": "7.4.0", "version": "7.3.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "addon-tools-raub", "name": "addon-tools-raub",
"version": "7.4.0", "version": "7.3.0",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/node": "^20.8.3",
"eslint": "^8.51.0", "eslint": "^8.51.0",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"node-addon-api": "^7.0.0", "node-addon-api": "^7.0.0",
@ -161,12 +160,6 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@types/node": {
"version": "20.8.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.3.tgz",
"integrity": "sha512-jxiZQFpb+NlH5kjW49vXxvxTjeeqlbsnTAdBTKpzEdPs9itay7MscYXz3Fo9VYFEsfQ6LJFitHad3faerLAjCw==",
"dev": true
},
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.10.0", "version": "8.10.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",

View File

@ -1,7 +1,7 @@
{ {
"author": "Luis Blanco <luisblanco1337@gmail.com>", "author": "Luis Blanco <luisblanco1337@gmail.com>",
"name": "addon-tools-raub", "name": "addon-tools-raub",
"version": "7.4.0", "version": "7.3.0",
"description": "Helpers for Node.js addons and dependency packages", "description": "Helpers for Node.js addons and dependency packages",
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",
@ -34,7 +34,7 @@
}, },
"scripts": { "scripts": {
"eslint": "eslint .", "eslint": "eslint .",
"test": "node --test --watch .", "test": "node --test --watch",
"test-ci": "node --test", "test-ci": "node --test",
"build-test": "cd test-addon && node-gyp rebuild -j max --silent && cd .." "build-test": "cd test-addon && node-gyp rebuild -j max --silent && cd .."
}, },
@ -46,14 +46,11 @@
"node-addon-api": "^7.0.0" "node-addon-api": "^7.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"node-addon-api": { "node-addon-api": { "optional": true }
"optional": true
}
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.8.3",
"eslint": "^8.51.0",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint": "^8.51.0",
"node-addon-api": "^7.0.0", "node-addon-api": "^7.0.0",
"typescript": "^5.2.2" "typescript": "^5.2.2"
} }

View File

@ -1,24 +0,0 @@
'use strict';
const { copy, exists } = require('./files');
const cpcpplint = async () => {
const cpplintDest = `${process.cwd()}/CPPLINT.cfg`.replace(/\\/g, '/');
const cpplintSrc = `${__dirname}/CPPLINT.cfg`.replace(/\\/g, '/');
if (!await exists(cpplintSrc) ) {
console.error('Error. File "CPPLINT.cfg" not found.');
return;
}
if (await exists(cpplintDest) ) {
console.warn('Warning. Dest "CPPLINT.cfg" exists and will be overwritten.');
}
await copy(cpplintSrc, cpplintDest);
console.log(`"CPPLINT.cfg" was copied to "${cpplintDest}".`);
};
module.exports = { cpcpplint };

View File

@ -5,7 +5,6 @@ module.exports = Object.assign(
{}, {},
require('./action-pack'), require('./action-pack'),
require('./cpbin'), require('./cpbin'),
require('./cpcpplint'),
require('./download'), require('./download'),
require('./files'), require('./files'),
require('./install'), require('./install'),