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

chore: add .prettierrc in repo root #2145

Merged
merged 2 commits into from Jul 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 8 additions & 24 deletions .changes/config.json
Expand Up @@ -217,41 +217,29 @@
"tauri-runtime": {
"path": "./core/tauri-runtime",
"manager": "rust",
"dependencies": [
"tauri-utils"
],
"dependencies": ["tauri-utils"],
"postversion": "node ../../.scripts/sync-prerelease.js ${ pkg.pkg } ${ release.type }"
},
"tauri-runtime-wry": {
"path": "./core/tauri-runtime-wry",
"manager": "rust",
"dependencies": [
"tauri-utils",
"tauri-runtime"
],
"dependencies": ["tauri-utils", "tauri-runtime"],
"postversion": "node ../../.scripts/sync-prerelease.js ${ pkg.pkg } ${ release.type }"
},
"tauri-codegen": {
"path": "./core/tauri-codegen",
"manager": "rust",
"dependencies": [
"tauri-utils"
]
"dependencies": ["tauri-utils"]
},
"tauri-macros": {
"path": "./core/tauri-macros",
"manager": "rust",
"dependencies": [
"tauri-codegen"
]
"dependencies": ["tauri-codegen"]
},
"tauri-build": {
"path": "./core/tauri-build",
"manager": "rust",
"dependencies": [
"tauri-codegen",
"tauri-utils"
],
"dependencies": ["tauri-codegen", "tauri-utils"],
"postversion": "node ../../.scripts/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }"
},
"tauri": {
Expand All @@ -268,9 +256,7 @@
"cli.js": {
"path": "./tooling/cli.js",
"manager": "javascript",
"dependencies": [
"cli.rs"
],
"dependencies": ["cli.rs"],
"postversion": "node ../../.scripts/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
"assets": [
{
Expand All @@ -282,14 +268,12 @@
"cli.rs": {
"path": "./tooling/cli.rs",
"manager": "rust",
"dependencies": [
"tauri-bundler"
],
"dependencies": ["tauri-bundler"],
"postversion": "cargo check"
},
"create-tauri-app": {
"path": "./tooling/create-tauri-app",
"manager": "javascript"
}
}
}
}
5 changes: 5 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none'
}
40 changes: 20 additions & 20 deletions .scripts/sync-cli-metadata.js
Expand Up @@ -10,36 +10,36 @@ we should look to find a more "rusty way" to import / "pin" a version value in o
rust binaries.
*/

const { readFileSync, writeFileSync } = require("fs");
const { readFileSync, writeFileSync } = require('fs')

const filePath = `../../tooling/cli.rs/metadata.json`;
const packageNickname = process.argv[2];
const bump = process.argv[3];
if (bump !== "prerelease") {
const filePath = `../../tooling/cli.rs/metadata.json`
const packageNickname = process.argv[2]
const bump = process.argv[3]
if (bump !== 'prerelease') {
throw new Error(
`We don't handle anything except prerelease right now. Exiting.`
);
)
}

const inc = (version) => {
const v = version.split("");
const n = v.pop();
return [...v, String(Number(n) + 1)].join("");
};
const v = version.split('')
const n = v.pop()
return [...v, String(Number(n) + 1)].join('')
}

// read file into js object
const metadata = JSON.parse(readFileSync(filePath, "utf-8"));
const metadata = JSON.parse(readFileSync(filePath, 'utf-8'))

// set field version
let version;
if (packageNickname === "cli.js") {
version = inc(metadata[packageNickname].version);
metadata[packageNickname].version = version;
let version
if (packageNickname === 'cli.js') {
version = inc(metadata[packageNickname].version)
metadata[packageNickname].version = version
} else {
version = inc(metadata[packageNickname]);
metadata[packageNickname] = version;
version = inc(metadata[packageNickname])
metadata[packageNickname] = version
}

writeFileSync(filePath, JSON.stringify(metadata, null, 2) + "\n");
console.log(`wrote ${version} for ${packageNickname} into metadata.json`);
console.dir(metadata);
writeFileSync(filePath, JSON.stringify(metadata, null, 2) + '\n')
console.log(`wrote ${version} for ${packageNickname} into metadata.json`)
console.dir(metadata)
25 changes: 18 additions & 7 deletions .scripts/sync-prerelease.js
Expand Up @@ -8,7 +8,7 @@ This script is solely intended to be run as part of the `covector version` step
keep the `tauri-runtime`, `tauri-runtime-wry` and `tauri-driver` crates version without the `beta` or `beta-rc` suffix.
*/

const { readFileSync, writeFileSync } = require("fs")
const { readFileSync, writeFileSync } = require('fs')

const packageNickname = process.argv[2]
const bump = process.argv[3]
Expand All @@ -19,7 +19,10 @@ let changelogPath

if (packageNickname === 'tauri-runtime') {
manifestPath = '../../core/tauri-runtime/Cargo.toml'
dependencyManifestPaths = ['../../core/tauri/Cargo.toml', '../../core/tauri-runtime-wry/Cargo.toml']
dependencyManifestPaths = [
'../../core/tauri/Cargo.toml',
'../../core/tauri-runtime-wry/Cargo.toml'
]
changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
} else if (packageNickname === 'tauri-runtime-wry') {
manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
Expand All @@ -33,16 +36,24 @@ if (packageNickname === 'tauri-runtime') {
throw new Error(`Unexpected package ${packageNickname}`)
}

let manifest = readFileSync(manifestPath, "utf-8")
manifest = manifest.replace(/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/, 'version = "$1"')
let manifest = readFileSync(manifestPath, 'utf-8')
manifest = manifest.replace(
/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/,
'version = "$1"'
)
writeFileSync(manifestPath, manifest)

let changelog = readFileSync(changelogPath, "utf-8")
let changelog = readFileSync(changelogPath, 'utf-8')
changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
writeFileSync(changelogPath, changelog)

for (const dependencyManifestPath of dependencyManifestPaths) {
let dependencyManifest = readFileSync(dependencyManifestPath, "utf-8")
dependencyManifest = dependencyManifest.replace(new RegExp(packageNickname + ' = { version = "(\\d+\\.\\d+\.\\d+)-[^0-9\.]+\.0"'), `${packageNickname} = { version = "$1"`)
let dependencyManifest = readFileSync(dependencyManifestPath, 'utf-8')
dependencyManifest = dependencyManifest.replace(
new RegExp(
packageNickname + ' = { version = "(\\d+\\.\\d+.\\d+)-[^0-9.]+.0"'
),
`${packageNickname} = { version = "$1"`
)
writeFileSync(dependencyManifestPath, dependencyManifest)
}