refactor(tauri.js) keep folder structure on /dist (#235)

This commit is contained in:
Lucas Fernandes Nogueira 2019-12-27 20:34:24 -03:00 committed by GitHub
parent 4bce0df301
commit 7845ec0e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 39 additions and 30 deletions

View File

@ -20,6 +20,6 @@ if (argv.help) {
process.exit(0)
}
const build = require('../dist/build')
const build = require('../dist/api/build')
build({ ctx: { debug: argv.debug } })

View File

@ -19,6 +19,6 @@ if (argv.help) {
process.exit(0)
}
const dev = require('../dist/dev')
const dev = require('../dist/api/dev')
dev()

View File

@ -1,5 +1,5 @@
const parseArgs = require('minimist')
const { tauricon } = require('../dist/tauricon')
const { tauricon } = require('../dist/api/tauricon')
/**
* @type {object}

View File

@ -39,7 +39,7 @@ if (argv.help) {
process.exit(0)
}
const init = require('../dist/init')
const init = require('../dist/api/init')
init({
directory: argv.d || process.cwd(),

View File

@ -95,6 +95,7 @@
"lint-staged": "9.5.0",
"lockfile-lint": "3.0.3",
"promise": "8.0.3",
"raw-loader": "^4.0.0",
"ts-loader": "6.2.1",
"typescript": "3.7.3",
"webpack": "4.41.4",

View File

@ -1,7 +1,5 @@
import { TauriConfig } from 'types'
import merge from 'webpack-merge'
import * as entry from '../entry'
import { tauriDir } from '../helpers/app-paths'
const getTauriConfig = require('../helpers/tauri-config')
import Runner from '../runner'
@ -18,7 +16,5 @@ module.exports = async (config: TauriConfig): Promise<void> => {
) as TauriConfig
)
entry.generate(tauriDir, tauriConfig)
return tauri.build(tauriConfig)
}

View File

@ -1,7 +1,5 @@
import { TauriConfig } from 'types'
import merge from 'webpack-merge'
import * as entry from '../entry'
import { tauriDir } from '../helpers/app-paths'
const getTauriConfig = require('../helpers/tauri-config')
import Runner from '../runner'
@ -19,7 +17,5 @@ module.exports = async (config: TauriConfig): Promise<void> => {
) as TauriConfig
)
entry.generate(tauriDir, tauriConfig)
return tauri.run(tauriConfig)
}

View File

@ -1,14 +1,11 @@
import { ensureDirSync, readFileSync, writeFileSync } from 'fs-extra'
import { ensureDirSync, writeFileSync } from 'fs-extra'
import compileTemplate from 'lodash.template'
import path from 'path'
import { TauriConfig } from './types/config'
export const generate = (outDir: string, cfg: TauriConfig): void => {
// this MUST be from the templates repo
const apiTemplate = readFileSync(
path.resolve(__dirname, '../templates/tauri.js'),
'utf-8'
)
const apiTemplate = require('../templates/tauri.js').default
const apiContent = compileTemplate(apiTemplate)(cfg)
ensureDirSync(outDir)

View File

@ -47,6 +47,8 @@ class Runner {
this.__whitelistApi(cfg, toml)
})
entry.generate(tauriDir, cfg)
const runningDevServer = devPath.startsWith('http')
let inlinedAssets: string[] = []
@ -56,8 +58,6 @@ class Runner {
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
entry.generate(tauriDir, cfg)
this.devPath = devPath
const features = runningDevServer ? ['dev-server'] : []
@ -121,12 +121,11 @@ class Runner {
this.__whitelistApi(cfg, toml)
})
const inlinedAssets = await this.__parseHtml(cfg, cfg.build.distDir)
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
entry.generate(tauriDir, cfg)
const inlinedAssets = await this.__parseHtml(cfg, cfg.build.distDir)
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
const features = [
cfg.tauri.embeddedServer.active ? 'embedded-server' : 'no-server'
]
@ -163,7 +162,7 @@ class Runner {
const distIndexPath = path.join(indexDir, 'index.html')
if (!existsSync(distIndexPath)) {
warn(
`Error: cannot find index.html in "${indexDir}". Did you forget to build your web code or update the build.distDir in tauri.conf.js?`
`Error: cannot find index.html in "${indexDir}". Did you forget to build your web code or update the build.distDir in tauri.conf.json?`
)
reject(new Error('Could not find index.html in dist dir.'))
}

View File

@ -66,7 +66,7 @@ Run \`tauri init --force template\` to overwrite.`)
try {
removeSync(dir)
copyTemplates({
source: resolve(__dirname, '../templates/src-tauri'),
source: resolve(__dirname, '../../templates/src-tauri'),
scope: {
tauriDep
},

View File

@ -3,11 +3,11 @@ const nodeExternals = require('webpack-node-externals')
module.exports = {
entry: {
build: './src/api/build.ts',
dev: './src/api/dev.ts',
init: './src/api/init.ts',
tauricon: './src/api/tauricon.ts',
'tauri-config': './src/helpers/tauri-config.ts'
'api/build': './src/api/build.ts',
'api/dev': './src/api/dev.ts',
'api/init': './src/api/init.ts',
'api/tauricon': './src/api/tauricon.ts',
'helpers/tauri-config': './src/helpers/tauri-config.ts'
},
mode: process.env.NODE_ENV || 'development',
devtool: 'source-map',
@ -17,6 +17,10 @@ module.exports = {
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /tauri\.js$/i,
loader: 'raw-loader'
}
]
},

View File

@ -6678,6 +6678,14 @@ randomfill@^1.0.3:
randombytes "^2.0.5"
safe-buffer "^5.1.0"
raw-loader@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.0.tgz#d639c40fb9d72b5c7f8abc1fb2ddb25b29d3d540"
integrity sha512-iINUOYvl1cGEmfoaLjnZXt4bKfT2LJnZZib5N/LLyAphC+Dd11vNP9CNVb38j+SAJpFI1uo8j9frmih53ASy7Q==
dependencies:
loader-utils "^1.2.3"
schema-utils "^2.5.0"
rc@^1.0.1, rc@^1.2.7:
version "1.2.8"
resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
@ -7139,6 +7147,14 @@ schema-utils@^1.0.0:
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"
schema-utils@^2.5.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.6.1.tgz#eb78f0b945c7bcfa2082b3565e8db3548011dc4f"
integrity sha512-0WXHDs1VDJyo+Zqs9TKLKyD/h7yDpHUhEFsM2CzkICFdoX1av+GBq/J2xRTFfsQO5kBfhZzANf2VcIm84jqDbg==
dependencies:
ajv "^6.10.2"
ajv-keywords "^3.4.1"
seek-bzip@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc"