fix(cli.js): revert ESM distribution (#2457)

This commit is contained in:
Lucas Fernandes Nogueira 2021-08-16 20:15:49 -03:00 committed by GitHub
parent fbb405ba90
commit 01ad29257c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 240 additions and 178 deletions

View File

@ -0,0 +1,5 @@
---
"cli.js": patch
---
Reverts ESM distribution.

View File

@ -6,7 +6,7 @@ module.exports = {
targets: {
node: 'current'
},
modules: false
modules: 'commonjs'
}
],
'@babel/preset-typescript'

View File

@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import {
installDependencies,
updateDependencies
} from '../dist/api/dependency-manager.js'
async function run() {
const {
installDependencies,
updateDependencies
} = require('../dist/api/dependency-manager')
const choice = process.argv[2]
if (choice === 'install') {
await installDependencies()

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import parseArgs from 'minimist'
import tauricon from '../dist/api/tauricon.js'
const parseArgs = require('minimist')
const { tauricon } = require('../dist/api/tauricon')
/**
* @type {object}

View File

@ -3,11 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import chalk from 'chalk'
import updateNotifier from 'update-notifier'
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const chalk = require('chalk')
const pkg = require('../package.json')
const updateNotifier = require('update-notifier')
const cmds = ['icon', 'deps']
const rustCliCmds = ['dev', 'build', 'init', 'info', 'sign']
@ -68,9 +66,9 @@ ${chalk.yellow('Options')}
process.argv.splice(2, 1)
}
console.log(`[tauri]: running ${command}`)
await import(`./tauri-${command}.js`)
require(`./tauri-${command}`)
} else {
const { runOnRustCli } = await import('../dist/helpers/rust-cli.js')
const { runOnRustCli } = require('../dist/helpers/rust-cli')
if (process.argv && process.env.NODE_ENV !== 'test') {
process.argv.splice(0, 3)
}
@ -82,16 +80,19 @@ ${chalk.yellow('Options')}
).promise
.then(() => {
if (command === 'init' && !process.argv.some((arg) => arg === '--ci')) {
return import('../dist/api/dependency-manager.js').then(
({ installDependencies }) => installDependencies()
)
const {
installDependencies
} = require('../dist/api/dependency-manager')
return installDependencies()
}
})
.catch(() => process.exit(1))
}
}
export default tauri
module.exports = {
tauri
}
// on test we use the module.exports
if (process.env.NODE_ENV !== 'test') {

View File

@ -1,4 +1,4 @@
export default {
module.exports = {
globals: {
__DEV__: true
},
@ -8,24 +8,22 @@ export default {
// cache: false,
// verbose: true,
// watch: true,
// TODO: coverage does not work with esm
// collectCoverage: true,
// coverageDirectory: '<rootDir>/test/jest/coverage',
// collectCoverageFrom: [
// '<rootDir>/bin/**/*.js',
// '<rootDir>/helpers/**/*.js',
// '<rootDir>/api/**/*.js'
// ],
// coverageReporters: ['json-summary', 'text', 'lcov'],
// coverageThreshold: {
// global: {
// branches: 50,
// functions: 50,
// lines: 50,
// statements: 50
// }
// },
collectCoverage: true,
coverageDirectory: '<rootDir>/test/jest/coverage',
collectCoverageFrom: [
'<rootDir>/bin/**/*.js',
'<rootDir>/helpers/**/*.js',
'<rootDir>/api/**/*.js'
],
coverageReporters: ['json-summary', 'text', 'lcov'],
coverageThreshold: {
global: {
// branches: 50,
// functions: 50,
// lines: 50,
// statements: 50
}
},
testMatch: [
'<rootDir>/test/jest/__tests__/**/*.spec.js',
'<rootDir>/test/jest/__tests__/**/*.test.js'
@ -39,12 +37,11 @@ export default {
'^api/(.*)$': '<rootDir>/src/api/$1',
'^templates/(.*)$': '<rootDir>/src/templates/$1',
'^test/(.*)$': '<rootDir>/test/$1',
'../../package.json': '<rootDir>/package.json',
'node:(.*)$': '$1'
'../../package.json': '<rootDir>/package.json'
},
transform: {
'\\.toml$': 'jest-transform-toml',
'\\.(js|ts)$': 'babel-jest'
},
extensionsToTreatAsEsm: ['.ts']
transformIgnorePatterns: ['node_modules/(?!(is-png|imagemin|p-pipe)/)']
}

View File

@ -2,7 +2,6 @@
"name": "@tauri-apps/cli",
"version": "1.0.0-beta.7",
"description": "Command line interface for building Tauri apps",
"type": "module",
"bin": {
"tauri": "./bin/tauri.js"
},
@ -18,10 +17,10 @@
"scripts": {
"build": "rimraf ./dist && webpack --progress",
"build-release": "rimraf ./dist && cross-env NODE_ENV=production webpack",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --forceExit --no-cache --testPathIgnorePatterns=\"(build|dev)\"",
"test": "jest --runInBand --no-cache --testPathIgnorePatterns=\"(build|dev)\"",
"pretest": "yarn build",
"prepublishOnly": "yarn build-release",
"test:local": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --forceExit",
"test:local": "jest --runInBand",
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
@ -44,7 +43,7 @@
"access": "public"
},
"engines": {
"node": ">= 12.20.0",
"node": ">= 12.13.0",
"npm": ">= 6.6.0",
"yarn": ">= 1.19.1"
},
@ -73,7 +72,6 @@
"@babel/core": "7.15.0",
"@babel/preset-env": "7.15.0",
"@babel/preset-typescript": "7.15.0",
"@jest/globals": "27.0.6",
"@types/cross-spawn": "6.0.2",
"@types/fs-extra": "9.0.12",
"@types/global-agent": "2.1.1",
@ -100,6 +98,7 @@
"lockfile-lint": "4.6.2",
"prettier": "2.3.2",
"promise": "8.1.0",
"raw-loader": "4.0.2",
"rimraf": "3.0.2",
"toml-loader": "1.0.0",
"ts-loader": "9.2.5",

View File

@ -13,12 +13,9 @@ import { getCrateLatestVersion, semverLt } from './util'
import logger from '../../helpers/logger'
import { resolve as appResolve, tauriDir } from '../../helpers/app-paths'
import { readFileSync, writeFileSync, existsSync } from 'fs'
import toml from '@tauri-apps/toml'
import inquirer from 'inquirer'
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const toml = require('@tauri-apps/toml')
const log = logger('dependency:crates')
const dependencies = ['tauri']
@ -26,8 +23,7 @@ const dependencies = ['tauri']
function readToml<T>(tomlPath: string): T | null {
if (existsSync(tomlPath)) {
const manifest = readFileSync(tomlPath).toString()
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return toml.parse(manifest) as T
return toml.parse(manifest) as any as T
}
return null
}
@ -128,7 +124,6 @@ async function manageDependencies(
if (installedDeps.length || updatedDeps.length) {
writeFileSync(
appResolve.tauri('Cargo.toml'),
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
toml.stringify(manifest as any)
)
}

View File

@ -9,16 +9,17 @@ import * as npmPackages from './npm-packages'
const log = logger('dependency:manager')
export async function installDependencies(): Promise<void> {
log('Installing missing dependencies...')
await rust.install()
await cargoCrates.install()
await npmPackages.install()
}
export async function updateDependencies(): Promise<void> {
log('Updating dependencies...')
await rust.update()
await cargoCrates.update()
await npmPackages.update()
module.exports = {
async installDependencies() {
log('Installing missing dependencies...')
await rust.install()
await cargoCrates.install()
await npmPackages.install()
},
async updateDependencies() {
log('Updating dependencies...')
await rust.update()
await cargoCrates.update()
await npmPackages.update()
}
}

View File

@ -8,12 +8,10 @@ import getScriptVersion from '../../helpers/get-script-version'
import { downloadRustup } from '../../helpers/download-binary'
import logger from '../../helpers/logger'
import { createWriteStream, unlinkSync, existsSync } from 'fs'
import { dirname, resolve } from 'path'
import { resolve } from 'path'
import { platform } from 'os'
import https from 'https'
import { fileURLToPath } from 'url'
const currentDirName = dirname(fileURLToPath(import.meta.url))
const log = logger('dependency:rust')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -38,7 +36,7 @@ async function download(url: string, dest: string): Promise<void> {
async function installRustup(): Promise<void> {
const assetName =
platform() === 'win32' ? 'rustup-init.exe' : 'rustup-init.sh'
const rustupPath = resolve(currentDirName, `../../bin/${assetName}`)
const rustupPath = resolve(__dirname, `../../bin/${assetName}`)
if (!existsSync(rustupPath)) {
await downloadRustup()
}

View File

@ -18,7 +18,7 @@
* @license MIT
*/
import * as fsExtra from 'fs-extra'
import { access, ensureDir, ensureFileSync, writeFileSync } from 'fs-extra'
import imagemin, { Plugin } from 'imagemin'
import optipng from 'imagemin-optipng'
import zopfli from 'imagemin-zopfli'
@ -31,14 +31,7 @@ import { appDir, tauriDir } from '../helpers/app-paths'
import logger from '../helpers/logger'
import * as settings from '../helpers/tauricon.config'
import chalk from 'chalk'
import { createRequire } from 'module'
// @ts-expect-error
const { access, ensureDir, ensureFileSync, writeFileSync } = fsExtra.default
const require = createRequire(import.meta.url)
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require('../../package.json')
import { version } from '../../package.json'
const log = logger('app:spawn')
const warn = logger('app:spawn', chalk.red)
@ -207,7 +200,7 @@ const spinner = (): NodeJS.Timeout | null => {
}, 500)
}
const tauricon = {
const tauricon = (exports.tauricon = {
validate: async function (src: string, target: string) {
await validate(src, target)
return typeof image === 'object'
@ -519,6 +512,12 @@ const tauricon = {
throw err
}
}
}
})
/* eslint-enable @typescript-eslint/restrict-template-expressions */
export default tauricon
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = tauricon
}
exports.tauricon = tauricon
}

View File

@ -14,7 +14,7 @@ function resolvePath(basePath: string, dir: string): string {
}
const getAppDir = (): string => {
let dir = process.env.__TAURI_TEST_APP_DIR ?? process.cwd()
let dir = process.cwd()
let count = 0
// only go up three folders max
@ -26,7 +26,9 @@ const getAppDir = (): string => {
dir = normalize(join(dir, '..'))
}
warn("Couldn't recognize the current folder as a part of a Tauri project")
warn(
"Couldn't find recognize the current folder as a part of a Tauri project"
)
process.exit(1)
}

View File

@ -1,25 +1,15 @@
import { promisify } from 'util'
import stream from 'stream'
import { promisify } from 'util'
import fs from 'fs'
import got from 'got'
import { CargoManifest } from '../types/cargo'
import path from 'path'
import { bootstrap } from 'global-agent'
import { fileURLToPath } from 'url'
import { createRequire } from 'module'
const pipeline = promisify(stream.pipeline)
// Webpack reads the file at build-time, so this becomes a static var
// @ts-expect-error
import manifest from '../../../cli.rs/Cargo.toml'
const tauriCliManifest = manifest as CargoManifest
const currentDirName = path.dirname(fileURLToPath(import.meta.url))
const require = createRequire(import.meta.url)
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires */
const got = require('got')
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires */
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const pipeline = promisify(stream.pipeline)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
const tauriCliManifest = require('../../../cli.rs/Cargo.toml') as CargoManifest
const downloads: { [url: string]: boolean } = {}
@ -54,15 +44,13 @@ async function downloadBinaryRelease(
// TODO: Check hash of download
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, security/detect-non-literal-fs-filename
await pipeline(got.stream(url), fs.createWriteStream(outPath)).catch(
(e: unknown) => {
try {
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.unlinkSync(outPath)
} catch {}
throw e
}
)
await pipeline(got.stream(url), fs.createWriteStream(outPath)).catch((e) => {
try {
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.unlinkSync(outPath)
} catch {}
throw e
})
// eslint-disable-next-line security/detect-object-injection
downloads[url] = true
// eslint-disable-next-line security/detect-non-literal-fs-filename
@ -83,7 +71,7 @@ async function downloadCli(): Promise<void> {
throw Error('Unsupported platform')
}
const extension = platform === 'windows' ? '.exe' : ''
const outPath = path.join(currentDirName, `../../bin/tauri-cli${extension}`)
const outPath = path.join(__dirname, `../../bin/tauri-cli${extension}`)
console.log('Downloading Rust CLI...')
await downloadBinaryRelease(
`tauri-cli-v${version}`,
@ -99,7 +87,7 @@ async function downloadRustup(): Promise<void> {
return await downloadBinaryRelease(
'rustup',
assetName,
path.join(currentDirName, `../../bin/${assetName}`)
path.join(__dirname, `../../bin/${assetName}`)
)
}

View File

@ -2,24 +2,25 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { CargoManifest } from '../types/cargo'
import { existsSync } from 'fs'
import { resolve, join, dirname } from 'path'
import { resolve, join } from 'path'
import { spawnSync, spawn } from './spawn'
import { CargoManifest } from '../types/cargo'
import { downloadCli } from './download-binary'
import { fileURLToPath } from 'url'
// Webpack reads the file at build-time, so this becomes a static var
// @ts-expect-error
import manifest from '../../../cli.rs/Cargo.toml'
const tauriCliManifest = manifest as CargoManifest
const currentDirName = dirname(fileURLToPath(import.meta.url))
const currentTauriCliVersion = (): string => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const tauriCliManifest =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../../cli.rs/Cargo.toml') as CargoManifest
return tauriCliManifest.package.version
}
export async function runOnRustCli(
command: string,
args: string[]
): Promise<{ pid: number; promise: Promise<void> }> {
const targetPath = resolve(currentDirName, '../..')
const targetPath = resolve(__dirname, '../..')
const targetCliPath = join(
targetPath,
'bin/tauri-cli' + (process.platform === 'win32' ? '.exe' : '')
@ -79,8 +80,7 @@ export async function runOnRustCli(
targetPath,
'tauri-cli',
'--version',
// eslint-disable-next-line
tauriCliManifest.package.version
currentTauriCliVersion()
],
process.cwd()
)

View File

@ -1,13 +1,13 @@
import path from 'path'
import * as fixtureSetup from '../fixtures/app-test-setup.js'
import { spawn } from 'helpers/spawn'
const path = require('path')
const fixtureSetup = require('../fixtures/app-test-setup')
const appDir = path.join(fixtureSetup.fixtureDir, 'app')
const distDir = path.join(appDir, 'dist')
const spawn = require('helpers/spawn').spawn
function runBuildTest(args) {
fixtureSetup.initJest('app')
console.log(2)
const { build } = require('dist/api/cli')
return new Promise(async (resolve, reject) => {
try {
let success = false
@ -20,7 +20,7 @@ function runBuildTest(args) {
setTimeout(resolve, 2000)
})
process.chdir(appDir)
const { build } = await import('dist/api/cli')
console.log(server)
const { promise } = await build(args)
await promise

View File

@ -1,11 +1,10 @@
import path from 'path'
import isRunning from 'is-running'
import http from 'http'
import { statSync, createReadStream } from 'fs'
import * as fixtureSetup from '../fixtures/app-test-setup.js'
const path = require('path')
const fixtureSetup = require('../fixtures/app-test-setup')
const distDir = path.resolve(fixtureSetup.fixtureDir, 'app', 'dist')
function startDevServer() {
const http = require('http')
const { statSync, createReadStream } = require('fs')
const app = http.createServer((req, res) => {
if (req.method === 'GET') {
if (req.url === '/') {
@ -31,12 +30,13 @@ function startDevServer() {
function runDevTest(tauriConfig) {
fixtureSetup.initJest('app')
const { dev } = require('dist/api/cli')
return new Promise(async (resolve, reject) => {
try {
process.chdir(path.join(fixtureSetup.fixtureDir, 'app'))
const { dev } = await import('dist/api/cli')
const { promise, pid } = await dev({ config: tauriConfig })
const isRunning = require('is-running')
let success = false
const checkIntervalId = setInterval(async () => {
if (!isRunning(pid) && !success) {

View File

@ -1,9 +1,4 @@
import { jest } from '@jest/globals'
import tauri from 'bin/tauri'
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const { version } = require('../../../package.json')
const { tauri } = require('bin/tauri')
describe('[CLI] cli.js', () => {
it('displays a help message', async () => {
@ -34,6 +29,7 @@ describe('[CLI] cli.js', () => {
it('gets you version', async () => {
jest.spyOn(console, 'log')
const tests = ['--version', '-v']
const version = require('../../../package.json').version
for (const test of tests) {
tauri([test])
expect(console.log.mock.calls[0][0]).toBe(version)

View File

@ -1,17 +1,54 @@
import * as appTestSetup from '../fixtures/app-test-setup.js'
const appTestSetup = require('../fixtures/app-test-setup')
appTestSetup.initJest('app')
const tauricon = require('api/tauricon')
describe('[CLI] tauri-icon internals', () => {
it('tells you the version', async () => {
const tauricon = (await import('api/tauricon')).default
it('tells you the version', () => {
const version = tauricon.version()
expect(!!version).toBe(true)
})
it('will not validate a non-file', async () => {
jest.spyOn(process, 'exit').mockImplementation(() => true)
await tauricon.validate(
'test/jest/fixtures/doesnotexist.png',
'test/jest/fixtures/'
)
expect(process.exit.mock.calls[0][0]).toBe(1)
jest.clearAllMocks()
})
it('will not validate a non-png', async () => {
jest.spyOn(process, 'exit').mockImplementation(() => true)
await tauricon.validate(
'test/jest/fixtures/notAMeme.jpg',
'test/jest/fixtures/'
)
expect(process.exit.mock.calls[0][0]).toBe(1)
jest.clearAllMocks()
})
it('should fail if PNG does not have transparency', async () => {
jest.spyOn(process, 'exit').mockImplementation(() => true)
await tauricon.validate(
'test/jest/fixtures/no-alpha.png',
'test/jest/fixtures/'
)
expect(process.exit.mock.calls[0][0]).toBe(1)
jest.clearAllMocks()
})
it('can validate an image as PNG', async () => {
const valid = await tauricon.validate(
'test/jest/fixtures/tauri-logo.png',
'test/jest/fixtures/'
)
expect(valid).toBe(true)
})
})
describe('[CLI] tauri-icon builder', () => {
it('will still use default compression if missing compression chosen', async () => {
const tauricon = (await import('api/tauricon')).default
const valid = await tauricon.make(
'test/jest/fixtures/tauri-logo.png',
'test/jest/tmp/missing',
@ -22,7 +59,6 @@ describe('[CLI] tauri-icon builder', () => {
it('will not validate a non-file', async () => {
try {
const tauricon = (await import('api/tauricon')).default
await tauricon.make(
'test/jest/fixtures/tauri-foo-not-found.png',
'test/jest/tmp/optipng',
@ -34,7 +70,6 @@ describe('[CLI] tauri-icon builder', () => {
})
it('makes a set of icons with optipng', async () => {
const tauricon = (await import('api/tauricon')).default
const valid = await tauricon.make(
'test/jest/fixtures/tauri-logo.png',
'test/jest/tmp/optipng',

View File

@ -1,25 +1,22 @@
import * as fixtureSetup from '../fixtures/app-test-setup.js'
import { resolve, dirname } from 'path'
import { writeFileSync, readFileSync } from 'fs'
import { init, build } from 'dist/api/cli'
import { fileURLToPath } from 'url'
const currentDirName = dirname(fileURLToPath(import.meta.url))
const fixtureSetup = require('../fixtures/app-test-setup')
const { resolve } = require('path')
const { writeFileSync, readFileSync } = require('fs')
describe('[CLI] cli.js template', () => {
it('init a project and builds it', async () => {
const cwd = process.cwd()
const fixturePath = resolve(currentDirName, '../fixtures/empty')
const fixturePath = resolve(__dirname, '../fixtures/empty')
const tauriFixturePath = resolve(fixturePath, 'src-tauri')
fixtureSetup.initJest('empty')
process.chdir(fixturePath)
const { init, build } = require('dist/api/cli')
const { promise } = await init({
directory: process.cwd(),
force: true,
tauriPath: resolve(currentDirName, '../../../../..'),
tauriPath: resolve(__dirname, '../../../../..'),
ci: true
})
await promise

View File

@ -1,21 +1,44 @@
import { jest } from '@jest/globals'
import path from 'path'
import http from 'http'
import { fileURLToPath } from 'url'
const path = require('path')
const process = require('process')
const currentDirName = path.dirname(fileURLToPath(import.meta.url))
const mockFixtureDir = path.resolve(currentDirName, '../fixtures')
const mockFixtureDir = path.resolve(__dirname, '../fixtures')
export const fixtureDir = mockFixtureDir
module.exports.fixtureDir = mockFixtureDir
export const initJest = (mockFixture) => {
jest.setTimeout(1200000)
const mockAppDir = path.join(mockFixtureDir, mockFixture)
process.env.__TAURI_TEST_APP_DIR = mockAppDir
function mockResolvePath(basePath, dir) {
return dir && path.isAbsolute(dir) ? dir : path.resolve(basePath, dir)
}
export const startServer = (onSuccess) => {
module.exports.initJest = (mockFixture) => {
jest.setTimeout(1200000)
jest.mock('helpers/non-webpack-require', () => {
return (path) => {
const value = require('fs').readFileSync(path).toString()
if (path.endsWith('.json')) {
return JSON.parse(value)
}
return value
}
})
jest.mock('helpers/app-paths', () => {
const path = require('path')
const appDir = path.join(mockFixtureDir, mockFixture)
const tauriDir = path.join(appDir, 'src-tauri')
return {
appDir,
tauriDir,
resolve: {
app: (dir) => mockResolvePath(appDir, dir),
tauri: (dir) => mockResolvePath(tauriDir, dir)
}
}
})
}
module.exports.startServer = (onSuccess) => {
const http = require('http')
const responses = {
writeFile: null,
readFile: null,

View File

@ -26,7 +26,7 @@ tauri-build = { path = "../../../../../../../core/tauri-build" }
serde_json = "1.0.66"
serde = "1.0"
serde_derive = "1.0"
tauri = { path = "../../../../../../../core/tauri", features = ["api-all"] }
tauri = { path = "../../../../../../../core/tauri", features =["api-all"]}
[features]
default = [ "custom-protocol" ]

View File

@ -1,7 +1,7 @@
import { jest } from '@jest/globals'
jest.setTimeout(1200000)
global.Promise = require('promise')
setTimeout(() => {
// do nothing
}, 1)

View File

@ -2,7 +2,7 @@
"compilerOptions": {
"outDir": "./dist/",
"strict": true,
"module": "es2020",
"module": "commonjs",
"target": "es5",
"allowJs": true,
"esModuleInterop": true,

View File

@ -2,7 +2,6 @@ const path = require('path')
const nodeExternals = require('webpack-node-externals')
module.exports = {
target: 'es2020',
entry: {
'api/cli': './src/api/cli.ts',
'api/tauricon': './src/api/tauricon.ts',
@ -20,6 +19,10 @@ module.exports = {
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /(templates|api)[\\/].+\.js/,
use: 'raw-loader'
},
{
test: /\.toml?$/,
use: 'toml-loader'
@ -31,19 +34,15 @@ module.exports = {
extensions: ['.ts', '.js']
},
output: {
library: {
type: 'module'
},
library: 'tauri',
libraryTarget: 'umd',
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
globalObject: 'this'
},
experiments: {
outputModule: true
},
externals: [
nodeExternals({
importType: 'module'
allowlist: ['imagemin', 'is-png', 'p-pipe', 'file-type']
})
],
externalsPresets: { node: true }

View File

@ -1222,7 +1222,7 @@
jest-mock "^27.0.6"
jest-util "^27.0.6"
"@jest/globals@27.0.6", "@jest/globals@^27.0.6":
"@jest/globals@^27.0.6":
version "27.0.6"
resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.0.6.tgz#48e3903f99a4650673d8657334d13c9caf0e8f82"
integrity sha512-DdTGCP606rh9bjkdQ7VvChV18iS7q0IMJVP1piwTWyWskol4iqcVwthZmoJEf7obE1nc34OpIyoVGPeqLC+ryw==
@ -2230,6 +2230,11 @@ base64-js@^1.3.1:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==
bin-build@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bin-build/-/bin-build-3.0.0.tgz#c5780a25a8a9f966d8244217e6c1f5082a143861"
@ -3138,6 +3143,11 @@ emoji-regex@^8.0.0:
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
emojis-list@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==
end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1:
version "1.4.4"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
@ -5266,6 +5276,15 @@ loader-runner@^4.2.0:
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384"
integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==
loader-utils@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0"
integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==
dependencies:
big.js "^5.2.2"
emojis-list "^3.0.0"
json5 "^2.1.2"
locate-path@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
@ -6216,6 +6235,14 @@ randombytes@^2.1.0:
dependencies:
safe-buffer "^5.1.0"
raw-loader@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.2.tgz#1aac6b7d1ad1501e66efdac1522c73e59a584eb6"
integrity sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==
dependencies:
loader-utils "^2.0.0"
schema-utils "^3.0.0"
rc@^1.2.7, rc@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"