Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish #547

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/release-cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
package:
- name: tauri-bundler
registryName: tauri-bundler
path: cli/tauri-bundler
publishPath: cli/tauri-bundler/target/package # not in workspace so target folder is nested
- name: tauri-core
registryName: tauri
path: tauri
- name: tauri-utils
registryName: tauri-utils
path: tauri-utils
publishPath: target/package
- name: tauri-api
registryName: tauri-api
Expand All @@ -31,9 +32,9 @@ jobs:
registryName: tauri-updater
path: tauri-updater
publishPath: target/package
- name: tauri-utils
registryName: tauri-utils
path: tauri-utils
- name: tauri-core
registryName: tauri
path: tauri
publishPath: target/package
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ jobs:
working-directory: ${{ matrix.package.path }}
run: |
echo "# Yarn Audit Results" | tee -a ${{runner.workspace }}/notes.md
echo "\n<details>" >> ${{runner.workspace }}/notes.md
echo "<summary>click to view</summary>\n" >> ${{runner.workspace }}/notes.md
echo "\`\`\`" >> ${{runner.workspace }}/notes.md
yarn audit 2>&1 | tee -a ${{runner.workspace }}/notes.md
echo "\`\`\`" >> ${{runner.workspace }}/notes.md
echo "</details>\n" >> ${{runner.workspace }}/notes.md
- name: Publish ${{ matrix.package.name }}
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
Expand Down
18 changes: 11 additions & 7 deletions cli/tauri.js/bin/tauri-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ if (argv.help) {
process.exit(0)
}

const build = require('../dist/api/build')
async function run () {
const build = require('../dist/api/build')

build({
ctx: {
debug: argv.debug,
target: argv.target
}
})
await build({
ctx: {
debug: argv.debug,
target: argv.target
}
}).promise
}

run()
16 changes: 10 additions & 6 deletions cli/tauri.js/bin/tauri-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ if (argv.help) {
process.exit(0)
}

const dev = require('../dist/api/dev')
async function run () {
const dev = require('../dist/api/dev')

dev({
ctx: {
exitOnPanic: argv['exit-on-panic']
}
})
await dev({
ctx: {
exitOnPanic: argv['exit-on-panic']
}
}).promise
}

run()
3 changes: 0 additions & 3 deletions cli/tauri.js/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ module.exports = {
'<rootDir>/test/jest/__tests__/**/*.spec.js',
'<rootDir>/test/jest/__tests__/**/*.test.js'
],
testPathIgnorePatterns: [
'(build|dev).spec.js'
],
moduleFileExtensions: ['ts', 'js', 'json'],
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/$1',
Expand Down
48 changes: 24 additions & 24 deletions cli/tauri.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tauri",
"version": "0.5.0",
"version": "0.5.1",
"description": "Multi-binding collection of libraries and templates for building Tauri apps",
"bin": {
"tauri": "./bin/tauri.js"
Expand All @@ -12,10 +12,10 @@
"scripts": {
"build": "webpack --progress",
"build-release": "yarn build --display none --progress false",
"test": "jest --runInBand --no-cache",
"test": "jest --runInBand --no-cache --testPathIgnorePatterns=\"(build|dev)\"",
"pretest": "yarn build",
"prepublishOnly": "yarn build-release",
"test:mac-local": "jest --runInBand",
"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",
Expand Down Expand Up @@ -44,65 +44,65 @@
"yarn": ">= 1.19.1"
},
"dependencies": {
"@tauri-apps/tauri-inliner": "1.14.0",
"@tauri-apps/tauri-inliner": "1.14.1",
"@tauri-apps/toml": "2.2.4",
"chalk": "3.0.0",
"chokidar": "3.3.1",
"cross-spawn": "7.0.1",
"fast-glob": "3.2.2",
"fs-extra": "8.1.0",
"fs-extra": "9.0.0",
"imagemin": "7.0.1",
"imagemin-optipng": "7.1.0",
"imagemin-pngquant": "8.0.0",
"imagemin-zopfli": "6.0.0",
"is-png": "2.0.0",
"isbinaryfile": "4.0.4",
"jsdom": "16.2.1",
"isbinaryfile": "4.0.5",
"jsdom": "16.2.2",
"lodash": "4.17.15",
"minimist": "1.2.4",
"minimist": "1.2.5",
"ms": "2.1.2",
"png2icons": "2.0.1",
"read-chunk": "3.2.0",
"sharp": "0.25.1",
"sharp": "0.25.2",
"webpack-merge": "4.2.2",
"webpack-shell-plugin": "0.5.0"
},
"devDependencies": {
"@babel/core": "7.8.7",
"@babel/preset-env": "7.8.7",
"@babel/preset-typescript": "7.8.3",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.0",
"@babel/preset-typescript": "7.9.0",
"@types/cross-spawn": "6.0.1",
"@types/fs-extra": "8.1.0",
"@types/imagemin": "7.0.0",
"@types/imagemin-optipng": "5.2.0",
"@types/jsdom": "16.1.0",
"@types/jsdom": "16.2.0",
"@types/lodash": "4.14.149",
"@types/ms": "0.7.31",
"@types/sharp": "0.24.0",
"@types/webpack-merge": "4.1.5",
"@typescript-eslint/eslint-plugin": "2.23.0",
"@typescript-eslint/parser": "2.23.0",
"babel-jest": "25.1.0",
"@typescript-eslint/eslint-plugin": "2.26.0",
"@typescript-eslint/parser": "2.26.0",
"babel-jest": "25.2.4",
"dotenv": "8.2.0",
"eslint": "6.8.0",
"eslint-config-standard-with-typescript": "14.0.0",
"eslint-plugin-import": "2.20.1",
"eslint-config-standard-with-typescript": "15.0.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-lodash-template": "0.15.0",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-standard": "4.0.1",
"husky": "4.2.3",
"is-running": "2.1.0",
"jest": "25.1.0",
"jest": "25.2.4",
"jest-mock-process": "1.3.2",
"lint-staged": "10.0.8",
"lockfile-lint": "4.1.0",
"lint-staged": "10.1.1",
"lockfile-lint": "4.2.2",
"promise": "8.1.0",
"raw-loader": "4.0.0",
"ts-loader": "6.2.1",
"ts-loader": "6.2.2",
"typescript": "3.8.3",
"webpack": "4.42.0",
"webpack": "4.42.1",
"webpack-cli": "3.3.11",
"webpack-node-externals": "1.7.2"
},
Expand Down
3 changes: 2 additions & 1 deletion cli/tauri.js/src/api/tauricon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ const validate = async (
if (target !== undefined) {
await ensureDir(target)
}
return checkSrc(src)
const res = await checkSrc(src)
return res
}

// TODO: should take end param?
Expand Down
10 changes: 8 additions & 2 deletions cli/tauri.js/src/helpers/app-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { join, normalize, resolve, sep } from 'path'
import logger from './logger'
const warn = logger('tauri', 'red')

function resolvePath(basePath: string, dir: string): string {
return dir.startsWith('/') || /^\S:/g.test(dir)
? dir
: resolve(basePath, dir)
}

const getAppDir = (): string => {
let dir = process.cwd()
let count = 0
Expand All @@ -24,8 +30,8 @@ const appDir = getAppDir()
const tauriDir = resolve(appDir, 'src-tauri')

const resolveDir = {
app: (dir: string) => resolve(appDir, dir),
tauri: (dir: string) => resolve(tauriDir, dir)
app: (dir: string) => resolvePath(appDir, dir),
tauri: (dir: string) => resolvePath(tauriDir, dir)
}

export { appDir, tauriDir, resolveDir as resolve }
13 changes: 9 additions & 4 deletions cli/tauri.js/src/helpers/tauri-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { existsSync } from 'fs-extra'
import { resolve } from 'path'
import { TauriConfig } from 'types'
import merge from 'webpack-merge'
import logger from '../helpers/logger'
Expand Down Expand Up @@ -58,13 +57,19 @@ const getTauriConfig = (cfg: Partial<TauriConfig>): TauriConfig => {

const runningDevServer = config.build.devPath && config.build.devPath.startsWith('http')
if (!runningDevServer) {
config.build.devPath = resolve(appPaths.tauriDir, config.build.devPath)
config.build.devPath = appPaths.resolve.tauri(config.build.devPath)
process.env.TAURI_DIST_DIR = appPaths.resolve.app(config.build.devPath)
}
if (config.build.distDir) {
config.build.distDir = resolve(appPaths.tauriDir, config.build.distDir)
config.build.distDir = appPaths.resolve.tauri(config.build.distDir)
process.env.TAURI_DIST_DIR = appPaths.resolve.app(config.build.distDir)
}

if (!process.env.TAURI_DIST_DIR) {
error("Couldn't resolve the dist dir. Make sure you have `devPath` or `distDir` under tauri.conf.json > build")
process.exit(1)
}

process.env.TAURI_DIST_DIR = appPaths.resolve.app(config.build.distDir)
process.env.TAURI_DIR = appPaths.tauriDir
process.env.TAURI_CONFIG = JSON.stringify(config)

Expand Down
2 changes: 1 addition & 1 deletion cli/tauri.js/templates/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build = "src/build.rs"
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = <%= tauriDep || `{ version = "0.4" }` %>
tauri = <%= tauriDep || `{ version = "0.5" }` %>

[target."cfg(windows)".build-dependencies]
winres = "0.1"
Expand Down
5 changes: 4 additions & 1 deletion cli/tauri.js/test/jest/__tests__/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function runBuildTest(tauriConfig) {
let success = false
const server = fixtureSetup.startServer(() => {
success = true
try {
process.kill(appPid)
} catch {}
// wait for the app process to be killed
setTimeout(resolve, 2000)
})
Expand All @@ -37,7 +40,7 @@ function runBuildTest(tauriConfig) {
reject("App didn't reply")
})
}
}, 2500)
}, 15000)
} catch (error) {
reject(error)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/tauri.js/test/jest/__tests__/template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('[CLI] tauri.js template', () => {
const init = require('api/init')
init({
directory: process.cwd(),
force: true,
force: 'all',
tauriPath: resolve(__dirname, '../../../../..')
})

Expand Down
60 changes: 50 additions & 10 deletions cli/tauri.js/test/jest/fixtures/app-test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const mockFixtureDir = path.resolve(__dirname, '../fixtures')

module.exports.fixtureDir = mockFixtureDir

function mockResolvePath (basePath, dir) {
return dir.startsWith('/') || /^\S:/g.test(dir)
? dir
: path.resolve(basePath, dir)
}

module.exports.initJest = (mockFixture) => {
jest.setTimeout(720000)
jest.mock('helpers/non-webpack-require', () => {
Expand All @@ -25,17 +31,44 @@ module.exports.initJest = (mockFixture) => {
appDir,
tauriDir,
resolve: {
app: dir => path.join(appDir, dir),
tauri: dir => path.join(tauriDir, dir)
app: dir => mockResolvePath(appDir, dir),
tauri: dir => mockResolvePath(tauriDir, dir)
}
}
})

jest.spyOn(process, 'exit').mockImplementation(() => {})
}

module.exports.startServer = (onReply) => {
module.exports.startServer = (onSuccess) => {
const http = require('http')

const responses = {
writeFile: null,
readFile: null,
writeFileWithDir: null,
readFileWithDir: null,
readDir: null,
readDirWithDir: null,
copyFile: null,
copyFileWithDir: null,
createDir: null,
createDirWithDir: null,
removeDir: null,
removeDirWithDir: null,
renameFile: null,
renameFileWithDir: null,
removeFile: null,
renameFileWithDir: null,
listen: null
}
function addResponse (response) {
responses[response.cmd] = true
if (!Object.values(responses).some(c => c === null)) {
server.close(onSuccess)
}
}

const app = http.createServer((req, res) => {
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*')
Expand All @@ -50,16 +83,23 @@ module.exports.startServer = (onReply) => {
}

if (req.method === 'POST') {
let body = ''
req.on('data', chunk => {
body += chunk.toString()
})
if (req.url === '/reply') {
let body = ''
req.on('data', chunk => {
body += chunk.toString()
req.on('end', () => {
const json = JSON.parse(body)
addResponse(json)
res.writeHead(200)
res.end()
})
}
if (req.url === '/error') {
req.on('end', () => {
expect(JSON.parse(body)).toStrictEqual({
msg: 'TEST'
})
server.close(onReply)
res.writeHead(200)
res.end()
throw new Error(body)
})
}
}
Expand Down
Loading