Selaa lähdekoodia

chore: tauri.js dead code elim (#1422)

* remove templates, only used it CTA

* help command is empty, remove

* delete files that aren't imported / required

* set files array to ignore src and config files

* remove unused deps

* add arch notes for future ref

* change file
Jacob Bolda 4 vuotta sitten
vanhempi
sitoutus
c718bd2382

+ 5 - 0
.changes/taurijs-dead-code-elim.md

@@ -0,0 +1,5 @@
+---
+"tauri.js": patch
+---
+
+Eliminate the dead code in tauri.js. Also removed some unused dependencies and updated the publish config that we are not publishing the Typescript files (since this is now primarily a CLI).

+ 11 - 0
cli/tauri.js/architecture.md

@@ -0,0 +1,11 @@
+# Contributing
+
+See the main document in the `.github` folder for general instructions. This document includes information regarding specific architecture choices.
+
+# Development and Publishing
+
+This package is primarily a CLI. This means that the output should not contain any Typescript, and only use the `bin` directory with `.js` (or files runnable directly in pure node) or the `dist` directory which includes processed Typescript files. Running `npm publish --dry-run` will give you a list of files and the package structure that are included when it is published. This may be helpful for understanding path requirements.
+
+The `scripts` folder is included for use in dependency manager to install rustup.
+
+Webpack is our current bundler of choice. It is not bundling the `node_modules` so our `package.json` dependency array needs to include anything required within the repository.

+ 0 - 0
cli/tauri.js/bin/tauri-help.js


+ 1 - 1
cli/tauri.js/bin/tauri.js

@@ -1,6 +1,6 @@
 #!/usr/bin/env node
 
-const cmds = ['help', 'icon', 'deps']
+const cmds = ['icon', 'deps']
 const rustCliCmds = ['dev', 'build', 'init', 'info']
 
 const cmd = process.argv[2]

+ 5 - 4
cli/tauri.js/package.json

@@ -5,6 +5,11 @@
   "bin": {
     "tauri": "./bin/tauri.js"
   },
+  "files": [
+    "bin/**",
+    "dist/**",
+    "scripts/**"
+  ],
   "funding": {
     "type": "opencollective",
     "url": "https://opencollective.com/tauri"
@@ -48,7 +53,6 @@
     "@tauri-apps/toml": "2.2.4",
     "chalk": "4.1.0",
     "cross-spawn": "7.0.3",
-    "fast-glob": "3.2.5",
     "fs-extra": "9.1.0",
     "imagemin": "7.0.1",
     "imagemin-optipng": "8.0.0",
@@ -56,8 +60,6 @@
     "imagemin-zopfli": "7.0.0",
     "inquirer": "8.0.0",
     "is-png": "2.0.0",
-    "isbinaryfile": "4.0.6",
-    "lodash": "4.17.21",
     "minimist": "1.2.5",
     "ms": "2.1.3",
     "png2icons": "2.0.1",
@@ -74,7 +76,6 @@
     "@types/imagemin": "7.0.0",
     "@types/imagemin-optipng": "5.2.0",
     "@types/inquirer": "7.3.1",
-    "@types/lodash": "4.14.168",
     "@types/ms": "0.7.31",
     "@types/semver": "7.3.4",
     "@types/sharp": "0.27.2",

+ 0 - 56
cli/tauri.js/src/helpers/copy-templates.ts

@@ -1,56 +0,0 @@
-// forked from https://github.com/quasarframework/quasar/blob/master/app/lib/app-extension/Extension.js
-import fglob from 'fast-glob'
-import fs from 'fs-extra'
-import { isBinaryFileSync as isBinary } from 'isbinaryfile'
-import { template } from 'lodash'
-import { join, resolve } from 'path'
-
-const copyTemplates = ({
-  source,
-  target,
-  scope
-}: {
-  source: string
-  target: string
-  scope?: object
-}): void => {
-  const files = fglob.sync(['**/*'], {
-    cwd: source
-  })
-
-  for (const rawPath of files) {
-    const targetRelativePath = rawPath
-      .split('/')
-      .map((name) => {
-        // dotfiles are ignored when published to npm, therefore in templates
-        // we need to use underscore instead (e.g. "_gitignore")
-        if (name.startsWith('_') && name.charAt(1) !== '_') {
-          return `.${name.slice(1)}`
-        }
-        if (name.startsWith('_') && name.charAt(1) === '_') {
-          return `${name.slice(1)}`
-        }
-        return name
-      })
-      .join('/')
-
-    const targetPath = join(target, targetRelativePath)
-    const sourcePath = resolve(source, rawPath)
-
-    fs.ensureFileSync(targetPath)
-
-    if (isBinary(sourcePath)) {
-      fs.copyFileSync(sourcePath, targetPath)
-    } else {
-      // eslint-disable-next-line security/detect-non-literal-fs-filename
-      const rawContent = fs.readFileSync(sourcePath, 'utf-8')
-      const compiled = template(rawContent, {
-        interpolate: /<%=([\s\S]+?)%>/g
-      })
-      // eslint-disable-next-line security/detect-non-literal-fs-filename
-      fs.writeFileSync(targetPath, compiled(scope), 'utf-8')
-    }
-  }
-}
-
-export default copyTemplates

+ 0 - 15
cli/tauri.js/src/helpers/on-shutdown.ts

@@ -1,15 +0,0 @@
-export default (fn: () => void): void => {
-  const cleanup = (): void => {
-    try {
-      fn()
-    } finally {
-      process.exit()
-    }
-  }
-
-  process.on('exit', cleanup)
-  process.on('SIGINT', cleanup)
-  process.on('SIGTERM', cleanup)
-  process.on('SIGHUP', cleanup)
-  process.on('SIGBREAK', cleanup)
-}

+ 0 - 54
cli/tauri.js/templates/recipes/react/App.css

@@ -1,54 +0,0 @@
-.App {
-  text-align: center;
-}
-
-.App-logo {
-  height: 20vmin;
-  pointer-events: none;
-}
-
-@media (prefers-reduced-motion: no-preference) {
-  .App-logo.rotate {
-    animation: App-logo-spin infinite 20s linear;
-  }
-}
-
-div.inline-logo {
-  display: flex;
-  flex-direction: row;
-  align-items: center;
-  justify-content: center;
-}
-
-div.inline-logo > img {
-  margin-right: 3vw;
-}
-
-div.inline-logo .smaller {
-  height: 10vh;
-}
-
-.App-header {
-  background-color: #282c34;
-  min-height: 100vh;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: center;
-  font-size: calc(10px + 2vmin);
-  color: white;
-}
-
-.App-link {
-  color: #61dafb;
-  margin-bottom: 5vh;
-}
-
-@keyframes App-logo-spin {
-  from {
-    transform: rotate(0deg);
-  }
-  to {
-    transform: rotate(360deg);
-  }
-}

+ 0 - 40
cli/tauri.js/templates/recipes/react/App.js

@@ -1,40 +0,0 @@
-import React from 'react'
-import logo from './logo.svg'
-import tauriCircles from './tauri.svg'
-import tauriWord from './wordmark.svg'
-import './App.css'
-
-function App() {
-  return (
-    <div className="App">
-      <header className="App-header">
-        <div className="inline-logo">
-          <img src={tauriCircles} className="App-logo rotate" alt="logo" />
-          <img src={tauriWord} className="App-logo smaller" alt="logo" />
-        </div>
-        <a
-          className="App-link"
-          href="https://tauri.studio"
-          target="_blank"
-          rel="noopener noreferrer"
-        >
-          Learn Tauri
-        </a>
-        <img src={logo} className="App-logo rotate" alt="logo" />
-        <a
-          className="App-link"
-          href="https://reactjs.org"
-          target="_blank"
-          rel="noopener noreferrer"
-        >
-          Learn React
-        </a>
-        <p>
-          Edit <code>src/App.js</code> and save to reload.
-        </p>
-      </header>
-    </div>
-  )
-}
-
-export default App

+ 0 - 21
cli/tauri.js/templates/recipes/react/tauri.svg

@@ -1,21 +0,0 @@
-<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 383.44479 435.98273" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
-    <g transform="translate(-703.62301,-1339.6611)">
-            <g transform="rotate(-19.354322)">
-                <circle cx="274.08301" cy="1813.09" r="32" fill="url(#d)"/>
-            </g>
-            <g transform="rotate(-19.354322)">
-                <circle cx="382.97299" cy="1719.61" r="32" fill="url(#c)"/>
-            </g>
-            <path d="m796.022 1418.15c-21.659 37.92-27.401 84.66-11.828 129 4.38 12.47 10.212 24.01 17.214 34.55 1.051 1.88 2.59 3.45 4.455 4.53 5.701 3.29 13.101 1.31 16.392-4.39 2.286-3.97 2.104-8.92-0.468-12.72l0.027-0.02c-6.097-9.09-11.178-19.08-14.98-29.9-24.177-68.83 11.861-143.9 80.692-168.08s143.904 11.86 168.084 80.69-11.87 143.91-80.699 168.09c-17.276 6.06-34.942 8.32-52.099 7.23h-0.052c-4.759-0.57-9.423 1.76-11.82 5.91-3.291 5.71-1.309 13.1 4.392 16.4 1.905 1.09 4.073 1.64 6.268 1.59 20.21 1.28 40.988-1.37 61.264-8.49 81.066-28.48 123.866-117.61 95.386-198.68s-117.609-123.86-198.678-95.38c-36.734 12.9-65.607 38.26-83.553 69.67z" fill="url(#b)" fill-rule="nonzero"/>
-            <path d="m724.265 1542.44c-21.659 37.92-27.397 84.66-11.824 129 28.476 81.07 117.602 123.86 198.67 95.39 81.069-28.48 123.859-117.61 95.389-198.68-4.33-12.34-10.09-23.77-16.991-34.21-1.05-2.05-2.668-3.75-4.659-4.91-5.701-3.29-13.101-1.31-16.392 4.39-2.287 3.98-2.105 8.93 0.467 12.72l-0.058 0.04c6.101 9.1 11.186 19.09 14.989 29.92 24.174 68.83-11.866 143.91-80.697 168.08-68.831 24.18-143.899-11.86-168.076-80.7-24.178-68.83 11.859-143.9 80.69-168.08 17.493-6.14 35.388-8.39 52.75-7.2l1e-3 -0.03c4.572 0.33 8.949-1.99 11.246-5.95 3.291-5.7 1.309-13.1-4.392-16.39-2.026-1.17-4.349-1.72-6.682-1.58-20.088-1.23-40.73 1.43-60.877 8.51-36.734 12.9-65.609 38.26-83.554 69.67z" fill="url(#a)" fill-rule="nonzero"/>
-        </g>
-    <defs>
-        <linearGradient id="d" x2="1" gradientTransform="matrix(48.6643,-41.7777,41.7777,48.6643,249.699,1834.02)" gradientUnits="userSpaceOnUse"><stop stop-color="#0096f2" offset="0"/><stop stop-color="#4cffc4" offset="1"/></linearGradient>
-        <linearGradient id="c" x2="1" gradientTransform="matrix(-48.5635,41.6911,-41.6911,-48.5635,407.745,1699.34)" gradientUnits="userSpaceOnUse"><stop stop-color="#ff8a11" offset="0"/><stop stop-color="#fff550" offset="1"/></linearGradient>
-        <linearGradient id="b" x2="1" gradientTransform="matrix(-150.612,260.867,-260.867,-150.612,960.685,1332.65)" gradientUnits="userSpaceOnUse"><stop stop-color="#ff8a11" offset="0"/><stop stop-color="#fff550" offset="1"/></linearGradient>
-        <linearGradient id="a" x2="1" gradientTransform="matrix(150.613,-260.87,260.87,150.613,781.584,1754.69)" gradientUnits="userSpaceOnUse"><stop stop-color="#0096f2" offset="0"/><stop stop-color="#4cffc4" offset="1"/></linearGradient>
-    
-        
-        
-    </defs>
-</svg>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 4
cli/tauri.js/templates/recipes/react/wordmark.svg


+ 1 - 11
cli/tauri.js/yarn.lock

@@ -1356,11 +1356,6 @@
   resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
   integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
 
-"@types/lodash@4.14.168":
-  version "4.14.168"
-  resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
-  integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==
-
 "@types/minimatch@*":
   version "3.0.4"
   resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
@@ -3443,7 +3438,7 @@ fast-deep-equal@^3.1.1:
   resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
   integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
 
-fast-glob@3.2.5, fast-glob@^3.0.3, fast-glob@^3.1.1:
+fast-glob@^3.0.3, fast-glob@^3.1.1:
   version "3.2.5"
   resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661"
   integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==
@@ -4464,11 +4459,6 @@ isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
   resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
   integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
 
-isbinaryfile@4.0.6:
-  version "4.0.6"
-  resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.6.tgz#edcb62b224e2b4710830b67498c8e4e5a4d2610b"
-  integrity sha512-ORrEy+SNVqUhrCaal4hA4fBzhggQQ+BaLntyPOdoEiwlKZW9BZiJXjg3RMiruE4tPEI3pyVPpySHQF/dKWperg==
-
 isexe@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä