cpp.js 1.0.0-beta.31 → 1.0.0-beta.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,8 +15,10 @@
15
15
  <a href="https://github.com/bugra9/cpp.js/discussions"><img alt="Discussions" src="https://img.shields.io/github/discussions/bugra9/cpp.js?style=for-the-badge" /></a>
16
16
  <a href="https://github.com/bugra9/cpp.js/issues"><img alt="Issues" src="https://img.shields.io/github/issues/bugra9/cpp.js?style=for-the-badge" /></a>
17
17
  <br />
18
+ <img alt="CodeQL" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/github-code-scanning/codeql?branch=main&style=for-the-badge&label=CodeQL">
18
19
  <img alt="Linux Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-linux.yml?branch=main&style=for-the-badge&label=Linux%20Build">
19
20
  <img alt="Macos Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-macos.yml?branch=main&style=for-the-badge&label=Macos%20Build">
21
+ <img alt="Windows Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-windows.yml?branch=main&style=for-the-badge&label=Windows%20Build">
20
22
  </div>
21
23
 
22
24
  <h3 align="center">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cpp.js",
3
- "version": "1.0.0-beta.31",
3
+ "version": "1.0.0-beta.32",
4
4
  "license": "MIT",
5
5
  "homepage": "https://cpp.js.org",
6
6
  "repository": "https://github.com/bugra9/cpp.js.git",
@@ -1,8 +1,8 @@
1
- import { glob } from 'glob';
1
+ import findFiles from '../utils/findFiles.js';
2
2
  import state from '../state/index.js';
3
3
 
4
4
  export default function getAllBridges() {
5
5
  return [
6
- ...glob.sync(`${state.config.paths.build}/bridge/*.i.cpp`, { absolute: true }),
6
+ ...findFiles(`${state.config.paths.build}/bridge/*.i.cpp`),
7
7
  ];
8
8
  }
@@ -1,15 +1,15 @@
1
- import { glob } from 'glob';
1
+ import findFiles from '../utils/findFiles.js';
2
2
  import state from '../state/index.js';
3
3
 
4
4
  export default function getDependLibs() {
5
5
  let dependLibs = [
6
- ...glob.sync(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { absolute: true, cwd: state.config.paths.project }),
6
+ ...findFiles(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { cwd: state.config.paths.project }),
7
7
  ];
8
8
  state.config.dependencyParameters.cmakeDepends.forEach((d) => {
9
9
  if (d.export.libName) {
10
10
  d.export.libName.forEach((fileName) => {
11
11
  if (d.platform['Emscripten-x86_64'].ignoreLibName?.includes(fileName)) return;
12
- dependLibs.push(...glob.sync(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { absolute: true, cwd: d.paths.project }));
12
+ dependLibs.push(...findFiles(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { cwd: d.paths.project }));
13
13
  });
14
14
  }
15
15
  });
package/src/bin.js CHANGED
@@ -3,7 +3,6 @@
3
3
  import fs from 'node:fs';
4
4
  import { execFileSync } from 'node:child_process';
5
5
  import { Command, Option } from 'commander';
6
- import { glob } from 'glob';
7
6
  import replace from 'replace';
8
7
 
9
8
  import { state } from './index.js';
@@ -18,6 +17,7 @@ import systemKeys from './utils/systemKeys.js';
18
17
 
19
18
  import { getDockerImage } from './utils/pullDockerImage.js';
20
19
  import { getContentHash } from './utils/hash.js';
20
+ import findFiles from './utils/findFiles.js';
21
21
 
22
22
  const packageJSON = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
23
23
 
@@ -262,8 +262,8 @@ function buildLib(platform) {
262
262
 
263
263
  const modules = [];
264
264
  state.config.paths.module.forEach((modulePath) => {
265
- modules.push(...glob.sync('**/*.i', { absolute: true, cwd: modulePath }));
266
- modules.push(...glob.sync('*.i', { absolute: true, cwd: modulePath }));
265
+ modules.push(...findFiles('**/*.i', { cwd: modulePath }));
266
+ modules.push(...findFiles('*.i', { cwd: modulePath }));
267
267
  });
268
268
  if (modules.length > 0) {
269
269
  fs.mkdirSync(`${state.config.paths.output}/prebuilt/${p}/swig`, { recursive: true });
@@ -289,7 +289,7 @@ function buildLib(platform) {
289
289
  async function createWasmJs() {
290
290
  let headers = [];
291
291
  state.config.paths.header.forEach((headerPath) => {
292
- headers.push(glob.sync('**/*.h', { absolute: true, cwd: headerPath }));
292
+ headers.push(findFiles('**/*.h', { cwd: headerPath }));
293
293
  });
294
294
  headers = headers.filter((path) => !!path.toString()).flat();
295
295
 
@@ -64,7 +64,7 @@ function getFilledConfig(config, options = { isDepend: false }) {
64
64
  newConfig.paths.bridge = (newConfig.paths.bridge || [...newConfig.paths.native, newConfig.paths.build])
65
65
  .map((p) => getPath(p));
66
66
  newConfig.paths.output = getPath(newConfig.paths.output) || newConfig.paths.build;
67
- newConfig.paths.cmake = options.isDepend ? getCMakeListsFilePath(newConfig.paths.output) : (
67
+ newConfig.paths.cmake = options.isDepend ? getPath(getCMakeListsFilePath(newConfig.paths.output)) : (
68
68
  getPath(newConfig.paths.cmake || getCMakeListsFilePath(newConfig.paths.project))
69
69
  );
70
70
  newConfig.paths.cmakeDir = getParentPath(newConfig.paths.cmake);
@@ -0,0 +1,5 @@
1
+ import { glob } from 'glob';
2
+
3
+ export default function findFiles(regex, options = {}) {
4
+ return glob.sync(regex, { absolute: true, posix: true, ...options }).map(p => p.replace('//?/', ''));
5
+ }
@@ -5,7 +5,7 @@ export default function getAbsolutePath(projectPath, path) {
5
5
  return null;
6
6
  }
7
7
  if (upath.isAbsolute(path)) {
8
- return path;
8
+ return upath.resolve(path);
9
9
  }
10
10
  if (projectPath) {
11
11
  return upath.resolve(upath.join(upath.resolve(projectPath), path));
@@ -1,10 +1,10 @@
1
- import { glob } from 'glob';
2
1
  import getParentPath from './getParentPath.js';
2
+ import findFiles from './findFiles.js';
3
3
 
4
4
  export default function getCMakeListsFilePath(basePath = process.cwd()) {
5
- let temp = glob.sync('CMakeLists.txt', { absolute: true, cwd: basePath });
5
+ let temp = findFiles('CMakeLists.txt', { cwd: basePath });
6
6
  if (temp.length === 0) {
7
- temp = glob.sync('*/CMakeLists.txt', { absolute: true, cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
7
+ temp = findFiles('*/CMakeLists.txt', { cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
8
8
  }
9
9
 
10
10
  if (temp.length > 0) return temp[0];