@companion-module/tools 2.7.1 → 3.0.1

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.
@@ -5,9 +5,6 @@
5
5
  "noImplicitAny": true,
6
6
  "moduleResolution": "node",
7
7
  "sourceMap": true,
8
- "paths": {
9
- "*": ["../node_modules/*"]
10
- },
11
8
  "declaration": false,
12
9
  "importHelpers": false,
13
10
  "listFiles": false,
@@ -16,7 +13,6 @@
16
13
  "lib": ["es2023"],
17
14
  "types": ["node"],
18
15
  "strict": true,
19
- "alwaysStrict": false,
20
16
  "forceConsistentCasingInFileNames": true,
21
17
  "noFallthroughCasesInSwitch": true,
22
18
  "noImplicitReturns": true,
package/eslint/config.mjs DELETED
@@ -1,155 +0,0 @@
1
- // @ts-check
2
-
3
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
4
- import eslint from '@eslint/js'
5
- import neslint from 'eslint-plugin-n'
6
-
7
- /**
8
- *
9
- * @template T
10
- * @param {Record<string, T | null | undefined>} obj
11
- * @returns {Record<string, T>}
12
- */
13
- function compactObj(obj) {
14
- /** @type {Record<string, T>} */
15
- const result = {}
16
-
17
- for (const [key, value] of Object.entries(obj)) {
18
- if (value) result[key] = value
19
- }
20
-
21
- return result
22
- }
23
-
24
- /***
25
- * @param {{
26
- * enableJest?: boolean,
27
- * enableTypescript?: boolean,
28
- * ignores?: string[],
29
- * commonRules?: Readonly<import('eslint').Linter.RulesRecord>,
30
- * typescriptRules?: Readonly<import('eslint').Linter.RulesRecord>,
31
- * }} [options={}] - Options to customize the config
32
- * @returns {Promise<import('eslint').Linter.Config[]>}
33
- */
34
- export async function generateEslintConfig(options = {}) {
35
- const tseslint = options.enableTypescript ? await import('typescript-eslint') : null
36
-
37
- /** @type {import('eslint').Linter.Config} */
38
- const result = {
39
- // extends: commonExtends,
40
- plugins: compactObj({
41
- '@typescript-eslint': tseslint ? tseslint.plugin : null,
42
- }),
43
- rules: {
44
- // Default rules to be applied everywhere
45
- 'prettier/prettier': 'error',
46
-
47
- ...eslint.configs.recommended.rules,
48
-
49
- 'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_(.+)' }],
50
- 'no-extra-semi': 'off',
51
- // 'n/no-unsupported-features/es-syntax': ['error', { ignores: ['modules'] }],
52
- 'no-use-before-define': 'off',
53
- 'no-warning-comments': ['error', { terms: ['nocommit', '@nocommit', '@no-commit'] }],
54
- // 'jest/no-mocks-import': 'off',
55
-
56
- ...(options.commonRules || {}),
57
- },
58
- }
59
-
60
- return [
61
- // setup the parser first
62
- tseslint
63
- ? {
64
- languageOptions: {
65
- parser: tseslint.parser,
66
- parserOptions: {
67
- project: true,
68
- },
69
- },
70
- }
71
- : null,
72
-
73
- neslint.configs['flat/recommended-script'],
74
- result,
75
- ...(tseslint ? tseslint.configs.recommendedTypeChecked : []),
76
- {
77
- // disable type-aware linting on JS files
78
- files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
79
- ...(tseslint ? tseslint.configs.disableTypeChecked : {}),
80
- },
81
- {
82
- files: ['*.mjs'],
83
- languageOptions: {
84
- sourceType: 'module',
85
- },
86
- },
87
- tseslint
88
- ? {
89
- files: ['**/*.ts', '**/*.cts', '**/*.mts'],
90
- rules: {
91
- '@typescript-eslint/no-explicit-any': 'off',
92
- '@typescript-eslint/interface-name-prefix': 'off',
93
- '@typescript-eslint/no-unused-vars': [
94
- 'error',
95
- { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_', varsIgnorePattern: '^_(.+)' },
96
- ],
97
- '@typescript-eslint/no-floating-promises': 'error',
98
- '@typescript-eslint/explicit-module-boundary-types': ['error'],
99
- '@typescript-eslint/promise-function-async': 'error',
100
- '@typescript-eslint/require-await': 'off', // conflicts with 'promise-function-async'
101
-
102
- /** Disable some annoyingly strict rules from the 'recommended-requiring-type-checking' pack */
103
- '@typescript-eslint/no-unsafe-assignment': 0,
104
- '@typescript-eslint/no-unsafe-member-access': 0,
105
- '@typescript-eslint/no-unsafe-argument': 0,
106
- '@typescript-eslint/no-unsafe-return': 0,
107
- '@typescript-eslint/no-unsafe-call': 0,
108
- '@typescript-eslint/restrict-template-expressions': 0,
109
- '@typescript-eslint/restrict-plus-operands': 0,
110
- '@typescript-eslint/no-redundant-type-constituents': 0,
111
- /** End 'recommended-requiring-type-checking' overrides */
112
-
113
- ...(options.typescriptRules || {}),
114
- },
115
- }
116
- : null,
117
- tseslint
118
- ? {
119
- files: ['**/__tests__/**/*', 'test/**/*'],
120
- rules: {
121
- '@typescript-eslint/ban-ts-ignore': 'off',
122
- '@typescript-eslint/ban-ts-comment': 'off',
123
- },
124
- }
125
- : null,
126
- {
127
- // disable type-aware linting on JS files
128
- files: [
129
- 'examples/**/*.js',
130
- 'examples/**/*.cjs',
131
- 'examples/**/*.mjs',
132
- 'examples/**/*.ts',
133
- 'examples/**/*.cts',
134
- 'examples/**/*.mts',
135
- ],
136
- rules: {
137
- 'no-process-exit': 'off',
138
- 'n/no-missing-import': 'off',
139
- },
140
- },
141
-
142
- // Add prettier at the end to give it final say on formatting
143
- eslintPluginPrettierRecommended,
144
- {
145
- // But lastly, ensure that we ignore certain paths
146
- ignores: ['**/dist/*', '/dist', '**/pkg/*', '**/docs/*', '**/generated/*', ...(options.ignores || [])],
147
- },
148
- {
149
- files: ['eslint.config.*'],
150
- rules: {
151
- 'n/no-unpublished-import': 'off',
152
- },
153
- },
154
- ].filter((v) => !!v)
155
- }
package/index.js DELETED
@@ -1 +0,0 @@
1
- throw new Error('Not importable!')
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- // The zx shebang doesn't resolve dependencies correctly
3
- import 'zx/globals'
4
-
5
- import { buildPackage } from './lib/build-util.js'
6
-
7
- if (process.platform === 'win32') {
8
- usePowerShell() // to enable powershell
9
- }
10
-
11
- if (argv.help) {
12
- console.log('Usage: companion-module-build [--dev] [--prerelease]')
13
- console.log('Builds the companion connection module')
14
- console.log(' --dev: Build in development mode. This will not minify the code, making it easier to debug.')
15
- console.log(' --prerelease: Build in prerelease mode. This gets added as metadata to the manifest')
16
- console.log(' --output <filename>: Output to a specific filename, without a file extension')
17
- process.exit(0)
18
- }
19
-
20
- let { validateManifest } = await import('@companion-module/base')
21
- if (!validateManifest) {
22
- // If a v2.x version of @companion-module/base is being used, it exports the function as a subpath export
23
- const manifestPkg = await import('@companion-module/base/manifest')
24
- validateManifest = manifestPkg.validateManifest
25
- }
26
-
27
- await buildPackage('@companion-module/base', validateManifest, 'connection', '>=1.4.0 <3.0.0')
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env node
2
- // The zx shebang doesn't resolve dependencies correctly
3
- import 'zx/globals'
4
-
5
- import { buildPackage } from './lib/build-util.js'
6
-
7
- if (process.platform === 'win32') {
8
- usePowerShell() // to enable powershell
9
- }
10
-
11
- if (argv.help) {
12
- console.log('Usage: companion-module-build [--dev] [--prerelease]')
13
- console.log('Builds the companion connection module')
14
- console.log(' --dev: Build in development mode. This will not minify the code, making it easier to debug.')
15
- console.log(' --prerelease: Build in prerelease mode. This gets added as metadata to the manifest')
16
- console.log(' --output <filename>: Output to a specific filename, without a file extension')
17
- process.exit(0)
18
- }
19
-
20
- const { validateSurfaceManifest } = await import('@companion-surface/base')
21
-
22
- await buildPackage('@companion-surface/base', validateSurfaceManifest, 'surface', '>=1.0.0 <2.0.0')
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- // The zx shebang doesn't resolve dependencies correctly
3
- import 'zx/globals'
4
-
5
- import path from 'path'
6
- import { fs } from 'zx'
7
- import { findUp } from 'find-up'
8
- import { validateManifest } from '@companion-module/base'
9
- import { createRequire } from 'module'
10
-
11
- if (process.platform === 'win32') {
12
- usePowerShell() // to enable powershell
13
- }
14
-
15
- const require = createRequire(import.meta.url)
16
-
17
- async function findModuleDir(cwd) {
18
- const stat = await fs.stat(cwd)
19
- if (stat.isFile()) cwd = path.dirname(cwd)
20
-
21
- const pkgJsonPath = await findUp('package.json', { cwd })
22
- return path.dirname(pkgJsonPath)
23
- }
24
-
25
- // const toolsDir = path.join(__dirname, '..')
26
- const toolsDir = await findModuleDir(require.resolve('@companion-module/tools'))
27
- const frameworkDir = await findModuleDir(require.resolve('@companion-module/base'))
28
- console.log(`Checking for: ${process.cwd()}`)
29
-
30
- console.log(`Tools path: ${toolsDir}`)
31
- console.log(`Framework path: ${frameworkDir}`)
32
-
33
- const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
34
-
35
- try {
36
- validateManifest(manifestJson)
37
- } catch (e) {
38
- console.error('Manifest validation failed', e)
39
- process.exit(1)
40
- }
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- // The zx shebang doesn't resolve dependencies correctly
3
- import 'zx/globals'
4
-
5
- import path from 'path'
6
- import { fs } from 'zx'
7
- import { findUp } from 'find-up'
8
- import { validateSurfaceManifest } from '@companion-surface/base'
9
- import { createRequire } from 'module'
10
-
11
- if (process.platform === 'win32') {
12
- usePowerShell() // to enable powershell
13
- }
14
-
15
- const require = createRequire(import.meta.url)
16
-
17
- async function findModuleDir(cwd) {
18
- const stat = await fs.stat(cwd)
19
- if (stat.isFile()) cwd = path.dirname(cwd)
20
-
21
- const pkgJsonPath = await findUp('package.json', { cwd })
22
- return path.dirname(pkgJsonPath)
23
- }
24
-
25
- // const toolsDir = path.join(__dirname, '..')
26
- const toolsDir = await findModuleDir(require.resolve('@companion-module/tools'))
27
- const frameworkDir = await findModuleDir(require.resolve('@companion-surface/base'))
28
- console.log(`Checking for: ${process.cwd()}`)
29
-
30
- console.log(`Tools path: ${toolsDir}`)
31
- console.log(`Framework path: ${frameworkDir}`)
32
-
33
- const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
34
-
35
- try {
36
- validateSurfaceManifest(manifestJson)
37
- } catch (e) {
38
- console.error('Manifest validation failed', e)
39
- process.exit(1)
40
- }
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env node
2
- // The zx shebang doesn't resolve dependencies correctly
3
- import 'zx/globals'
4
-
5
- import { fs, path, $ } from 'zx'
6
- import parseAuthor from 'parse-author'
7
-
8
- if (process.platform === 'win32') {
9
- usePowerShell() // to enable powershell
10
- }
11
-
12
- if (await fs.pathExists('companion/manifest.json')) {
13
- throw new Error('Manifest has already been created')
14
- }
15
-
16
- const pkgJsonStr = await fs.readFile('package.json')
17
- const pkgJson = JSON.parse(pkgJsonStr.toString())
18
-
19
- const maintainers = []
20
-
21
- function tryParsePerson(person) {
22
- try {
23
- if (person) {
24
- const rawAuthor = typeof person === 'string' ? parseAuthor(person) : person
25
- if (rawAuthor.name) {
26
- maintainers.push({
27
- name: rawAuthor.name,
28
- email: rawAuthor.email,
29
- })
30
- }
31
- }
32
- } catch (e) {
33
- // Ignore
34
- }
35
- }
36
-
37
- tryParsePerson(pkgJson.author)
38
- if (Array.isArray(pkgJson.contributors)) {
39
- for (const person of pkgJson.contributors) {
40
- tryParsePerson(person)
41
- }
42
- }
43
-
44
- let products = pkgJson.products || pkgJson.product || []
45
- if (typeof products === 'string') products = [products]
46
-
47
- const manifest = {
48
- id: pkgJson.name,
49
- name: pkgJson.name,
50
- shortname: pkgJson.shortname ?? pkgJson.name,
51
- description: pkgJson.description ?? pkgJson.name,
52
- version: '0.0.0',
53
- license: pkgJson.license,
54
- repository: pkgJson.repository?.url ?? `https://github.com/bitfocus/companion-module-${pkgJson.name}.git`,
55
- bugs: pkgJson.bugs?.url ?? `https://github.com/bitfocus/companion-module-${pkgJson.name}/issues`,
56
- maintainers: maintainers,
57
- legacyIds: [...(pkgJson.legacy || [])],
58
-
59
- runtime: {
60
- type: 'node22',
61
- api: 'nodejs-ipc',
62
- apiVersion: '0.0.0',
63
-
64
- entrypoint: path.join('../', pkgJson.main || 'index.js'),
65
- // universal: boolean
66
- },
67
-
68
- manufacturer: pkgJson.manufacturer ?? '',
69
- products: products,
70
- keywords: pkgJson.keywords || [],
71
- }
72
-
73
- const manifestDir = './companion'
74
- await fs.mkdirp(manifestDir)
75
- await fs.writeFile(path.join(manifestDir, 'manifest.json'), JSON.stringify(manifest, undefined, '\t'))
76
-
77
- if (await fs.pathExists('HELP.md')) {
78
- await fs.move('HELP.md', path.join(manifestDir, 'HELP.md'))
79
-
80
- // guess at what images might be needed by the help
81
- if (await fs.pathExists('images')) await fs.move('images', path.join(manifestDir, 'images'))
82
- if (await fs.pathExists('documentation')) await fs.move('documentation', path.join(manifestDir, 'documentation'))
83
- }
@@ -1,254 +0,0 @@
1
- import 'zx/globals'
2
-
3
- import path from 'path'
4
- import { fs } from 'zx'
5
- import { findUp } from 'find-up'
6
- import * as tar from 'tar'
7
- import { createRequire } from 'module'
8
- import * as semver from 'semver'
9
-
10
- function toSanitizedDirname(name) {
11
- return name.replace(/[^a-zA-Z0-9-\.]/g, '-').replace(/[-+]/g, '-')
12
- }
13
-
14
- const require = createRequire(import.meta.url)
15
-
16
- async function findModuleDir(cwd) {
17
- const stat = await fs.stat(cwd)
18
- if (stat.isFile()) cwd = path.dirname(cwd)
19
-
20
- const pkgJsonPath = await findUp('package.json', { cwd })
21
- return path.dirname(pkgJsonPath)
22
- }
23
-
24
- export async function buildPackage(frameworkPackageName, validateManifest, moduleType, versionRange) {
25
- // const toolsDir = path.join(__dirname, '..')
26
- const moduleDir = process.cwd()
27
- const toolsDir = await findModuleDir(require.resolve('@companion-module/tools'))
28
- const frameworkDir = await findModuleDir(require.resolve(frameworkPackageName))
29
- console.log(`Building for: ${process.cwd()}`)
30
-
31
- console.log(`Tools path: ${toolsDir}`)
32
- console.log(`Framework path: ${frameworkDir}`)
33
-
34
- // Check for Yarn PnP
35
- const pnpFile = path.join(moduleDir, '.pnp.cjs')
36
- const pnpFileAlt = path.join(moduleDir, '.pnp.js')
37
- if ((await fs.pathExists(pnpFile)) || (await fs.pathExists(pnpFileAlt))) {
38
- console.error("❌ Error: Yarn PnP (Plug'n'Play) is not supported.")
39
- console.error(' The companion module build process requires a traditional node_modules structure.')
40
- console.error(' Please add "nodeLinker: node-modules" to your .yarnrc.yml file and run "yarn install".')
41
- process.exit(1)
42
- }
43
-
44
- const srcPackageJson = JSON.parse(await fs.readFile(path.resolve('./package.json')))
45
- const frameworkPackageJson = JSON.parse(await fs.readFile(path.join(frameworkDir, 'package.json')))
46
-
47
- // Check framework version if range is specified
48
- if (versionRange && !semver.satisfies(frameworkPackageJson.version, versionRange, { includePrerelease: true })) {
49
- console.error(`Error: ${frameworkPackageName} version ${frameworkPackageJson.version} is not supported.`)
50
- console.error(`Required version range: ${versionRange}`)
51
- process.exit(1)
52
- }
53
-
54
- // clean old
55
- await fs.remove('pkg')
56
-
57
- // create new
58
- await fs.mkdir(`pkg`)
59
-
60
- const packageBaseDir = path.join('pkg')
61
-
62
- const webpackArgs = {
63
- ROOT: moduleDir,
64
- MODULETYPE: moduleType,
65
- }
66
- if (argv.dev || argv.debug) webpackArgs['dev'] = true
67
-
68
- const webpackArgsArray = []
69
- for (const [k, v] of Object.entries(webpackArgs)) {
70
- webpackArgsArray.push(`--env`, v === true ? k : `${k}=${v}`)
71
- }
72
-
73
- // build the code
74
- $.cwd = toolsDir
75
- const webpackConfig = path.join(toolsDir, 'webpack.config.cjs').replace(/\\/g, '/') // Fix slashes because windows is a pain
76
- // use npx to invoke. manual paths does not work on windows, and using `yarn` requires corepack
77
- await $`npx webpack -c ${webpackConfig} ${webpackArgsArray}`
78
- $.cwd = undefined
79
-
80
- // copy in the metadata
81
- await fs.copy('companion', path.join(packageBaseDir, 'companion'))
82
-
83
- // Copy the manifest, overriding some properties
84
- const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
85
- manifestJson.runtime.entrypoint = '../main.js'
86
- manifestJson.version = srcPackageJson.version
87
- manifestJson.runtime.api = 'nodejs-ipc'
88
- manifestJson.runtime.apiVersion = frameworkPackageJson.version
89
-
90
- // Bake in the prerelease flag if using module-base which is new enough
91
- if (semver.gt(manifestJson.runtime.apiVersion, '1.12.0-0')) {
92
- manifestJson.isPrerelease = !!argv.prerelease
93
- }
94
-
95
- await fs.writeFile(path.join(packageBaseDir, 'companion/manifest.json'), JSON.stringify(manifestJson))
96
-
97
- // Make sure the manifest is valid
98
- try {
99
- validateManifest(manifestJson)
100
- } catch (e) {
101
- console.error('Manifest validation failed', e)
102
- process.exit(1)
103
- }
104
-
105
- // Generate a minimal package.json
106
- const packageJson = {
107
- name: moduleType === 'connection' ? manifestJson.name : manifestJson.id,
108
- version: manifestJson.version,
109
- license: manifestJson.license,
110
- // Minimal content
111
- type: 'commonjs',
112
- dependencies: {},
113
- }
114
-
115
- // Ensure that any externals are added as dependencies
116
- const webpackExtPath = path.resolve('build-config.cjs')
117
- if (fs.existsSync(webpackExtPath)) {
118
- const webpackExt = require(webpackExtPath)
119
-
120
- // Add any external dependencies, with versions matching what is currntly installed
121
- if (webpackExt.externals) {
122
- const extArray = Array.isArray(webpackExt.externals) ? webpackExt.externals : [webpackExt.externals]
123
- for (const extGroup of extArray) {
124
- if (typeof extGroup === 'object') {
125
- // TODO - does this need to be a stricter object check?
126
-
127
- for (const external of Object.keys(extGroup)) {
128
- const extPath = await findUp('package.json', { cwd: require.resolve(external) })
129
- const extJson = JSON.parse(await fs.readFile(extPath))
130
- packageJson.dependencies[extJson.name] = extJson.version
131
- }
132
- }
133
- }
134
- }
135
-
136
- if (webpackExt.forceRemoveNodeGypFromPkg) {
137
- packageJson.resolutions = {
138
- 'node-gyp': 'npm:empty-npm-package@1.0.0',
139
- }
140
- }
141
-
142
- // Copy across any prebuilds that can be loaded corectly
143
- if (webpackExt.prebuilds) {
144
- await fs.mkdir(path.join(packageBaseDir, 'prebuilds'))
145
-
146
- for (const lib of webpackExt.prebuilds) {
147
- const srcDir = await findModuleDir(require.resolve(lib))
148
- const filesOrDirs = await fs.readdir(path.join(srcDir, 'prebuilds'))
149
- for (const fileOrDir of filesOrDirs) {
150
- await fs.copy(path.join(srcDir, 'prebuilds', fileOrDir), path.join(packageBaseDir, 'prebuilds', fileOrDir))
151
- }
152
- }
153
- }
154
-
155
- // copy extra files
156
- if (Array.isArray(webpackExt.extraFiles)) {
157
- const files = await globby(webpackExt.extraFiles, {
158
- expandDirectories: false,
159
- onlyFiles: false,
160
- })
161
-
162
- for (const file of files) {
163
- await fs.copy(file, path.join(packageBaseDir, path.basename(file)), {
164
- overwrite: false,
165
- })
166
- }
167
- }
168
- }
169
-
170
- // Copy node-gyp-build prebulds
171
- const webpackConfigJson = await require(webpackConfig)(webpackArgs)
172
- if (webpackConfigJson.node?.__dirname === true) {
173
- const copyNodeGypBuildPrebuilds = (thisPath) => {
174
- const nodeModPath = path.join(thisPath, 'node_modules')
175
- if (fs.existsSync(nodeModPath)) {
176
- for (const dir of fs.readdirSync(nodeModPath)) {
177
- const modDir = path.join(nodeModPath, dir)
178
- copyNodeGypBuildPrebuilds(modDir)
179
- }
180
- }
181
-
182
- const pkgJsonPath = path.join(thisPath, 'package.json')
183
- if (thisPath && fs.existsSync(pkgJsonPath)) {
184
- const dirPkgJsonStr = fs.readFileSync(pkgJsonPath)
185
- const dirPkgJson = JSON.parse(dirPkgJsonStr.toString())
186
-
187
- const prebuildsDir = path.join(thisPath, 'prebuilds')
188
- if (dirPkgJson.dependencies?.['node-gyp-build'] && fs.existsSync(prebuildsDir)) {
189
- fs.mkdirpSync(path.join(packageBaseDir, thisPath))
190
- fs.copySync(prebuildsDir, path.join(packageBaseDir, prebuildsDir))
191
-
192
- console.log('copying node-gyp-build prebuilds from', thisPath)
193
- }
194
- }
195
- }
196
-
197
- copyNodeGypBuildPrebuilds('')
198
- }
199
-
200
- // Write the package.json
201
- // packageJson.bundleDependencies = Object.keys(packageJson.dependencies)
202
- await fs.writeFile(path.join(packageBaseDir, 'package.json'), JSON.stringify(packageJson))
203
-
204
- // If we found any depenendencies for the pkg, install them
205
- if (Object.keys(packageJson.dependencies).length) {
206
- await fs.writeFile(path.join(packageBaseDir, 'yarn.lock'), '')
207
- await $`yarn --cwd ${packageBaseDir} install --no-immutable`
208
- }
209
-
210
- // Prune any excessive prebuilds
211
- const prebuildDirName = path.join(packageBaseDir, 'prebuilds')
212
- if (fs.existsSync(prebuildDirName)) {
213
- const prebuildDirs = await fs.readdir(prebuildDirName)
214
- for (const dir of prebuildDirs) {
215
- let keepDir = true
216
- if (dir.match(/freebsd/) || dir.match(/android/)) {
217
- // Unsupported platforms
218
- keepDir = false
219
- } else if (dir.match(/win32-ia32/)) {
220
- // 32bit windows is not supported
221
- keepDir = false
222
- } else if (dir.match(/linux(.+)musl/)) {
223
- // linux musl is not supported
224
- keepDir = false
225
- } else if (dir.match(/linux-arm$/) || dir.match(/linux-arm-gnueabihf/)) {
226
- // linux arm (non arm64) is not supported
227
- keepDir = false
228
- }
229
-
230
- if (!keepDir) {
231
- console.log('Removing unneeded prebuild dir:', dir)
232
- await fs.rm(path.join(prebuildDirName, dir), { recursive: true, force: true })
233
- }
234
- }
235
- }
236
-
237
- // Create tgz of the build
238
- let tgzFile = toSanitizedDirname(`${manifestJson.id}-${manifestJson.version}`)
239
- if (typeof argv['output'] === 'string') {
240
- // -o flag, to allow legacy behaviour creating pkg.tgz output
241
- tgzFile = argv['output']
242
- }
243
- tgzFile += '.tgz'
244
- console.log('Writing compressed package output to', tgzFile)
245
-
246
- await tar
247
- .create(
248
- {
249
- gzip: true,
250
- },
251
- [packageBaseDir],
252
- )
253
- .pipe(fs.createWriteStream(tgzFile))
254
- }
@@ -1,30 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es2022",
5
- "noImplicitAny": true,
6
- "moduleResolution": "node",
7
- "sourceMap": true,
8
- "paths": {
9
- "*": ["../node_modules/*"]
10
- },
11
- "declaration": false,
12
- "importHelpers": false,
13
- "listFiles": false,
14
- "traceResolution": false,
15
- "pretty": true,
16
- "lib": ["es2022"],
17
- "types": ["node"],
18
- "strict": true,
19
- "alwaysStrict": false,
20
- "forceConsistentCasingInFileNames": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "noImplicitReturns": true,
23
- "noUnusedLocals": true,
24
- "noUnusedParameters": true,
25
- "skipLibCheck": true,
26
- "allowSyntheticDefaultImports": true,
27
- "esModuleInterop": true
28
- },
29
- "compileOnSave": false
30
- }