Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGruber committed Aug 12, 2021
2 parents 7d37535 + 3654de0 commit 7f919e7
Show file tree
Hide file tree
Showing 12 changed files with 542 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist/
node_modules/
publish/
.env
tools/*.js
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## not released

## v1.0.1 (2021-08-12)

- Fix: #13 `Hotfolder Path` is missing in settings and `Ignore Files` shows wrong value

## v1.0.0 (2021-08-05)

- Improved: Use registerSettings instead of deprecated registerSetting
Expand Down
35 changes: 34 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "joplin-plugin-hotfolder",
"version": "1.0.0",
"version": "1.0.1",
"scripts": {
"dist": "webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive",
"prepare": "npm run test && npm run dist && husky install",
"update": "npm install -g generator-joplin && yo joplin --update",
"compileTools": "tsc -p ./tools/tsconfig.json",
"release": "npm run compileTools && node ./tools/createRelease.js",
"gitRelease": "node ./tools/createRelease.js --upload",
"test": "jest"
},
"license": "MIT",
Expand All @@ -14,13 +17,17 @@
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^14.0.14",
"axios": "^0.21.1",
"chalk": "^4.1.0",
"copy-webpack-plugin": "^6.1.0",
"dotenv": "^10.0.0",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"husky": "^6.0.0",
"jest": "^26.6.3",
"lint-staged": "^11.0.0",
"mime": "^2.5.2",
"moment": "^2.29.1",
"on-build-webpack": "^0.1.0",
"prettier": "2.3.0",
"tar": "^6.1.6",
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 1,
"id": "io.github.jackgruber.hotfolder",
"app_min_version": "1.8.1",
"version": "1.0.0",
"version": "1.0.1",
"name": "Hotfolder",
"description": "Monitors a locale folder and import the files as a new note.",
"author": "JackGruber",
Expand Down
17 changes: 8 additions & 9 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ export namespace settings {
label: "Hotfolder Path",
};

settingsObject["hotfolderPath" + (hotfolderNr == 0 ? "" : hotfolderNr)] =
{
value: ".*",
type: SettingItemType.String,
section: "hotfolderSection" + (hotfolderNr == 0 ? "" : hotfolderNr),
public: true,
label: "Ignore Files",
description: "Comma separated list of files which will be ignored.",
};
settingsObject["ignoreFiles" + (hotfolderNr == 0 ? "" : hotfolderNr)] = {
value: ".*",
type: SettingItemType.String,
section: "hotfolderSection" + (hotfolderNr == 0 ? "" : hotfolderNr),
public: true,
label: "Ignore Files",
description: "Comma separated list of files which will be ignored.",
};

settingsObject[
"extensionsAddAsText" + (hotfolderNr == 0 ? "" : hotfolderNr)
Expand Down
134 changes: 134 additions & 0 deletions tools/createRelease.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import * as path from "path";
import { getBranch, getInfo, nothingUncomitted } from "./git";
import {
runNpmVersion,
setPluginVersion,
updateChangelog,
getJPLFileName,
getChangelog,
} from "./utils";
import {
githubRelease,
ReleaseOptions,
AssetOptions,
githubAsset,
checkAuth,
ReproOptions,
} from "./github";
import * as dotenv from "dotenv";
import { execCommand } from "./execCommand";

async function createRelease() {
console.log("Create GitHub release");

const info = await getInfo();

const manifestFile = path.resolve(
path.join(__dirname, "../src/manifest.json")
);
const manifest = require(manifestFile);

const log = await getChangelog(manifest.version);
console.log(log);

const releaseOptions: ReleaseOptions = {
owner: info.owner,
repo: info.repo,
tag: `v${manifest.version}`,
name: `v${manifest.version}`,
prerelease: false,
token: process.env.GITHUB_TOKEN,
body: log,
};

console.log("githubRelease");
const releaseResult = await githubRelease(releaseOptions);

const jpl = await getJPLFileName();

const releaseAssetOptions: AssetOptions = {
token: process.env.GITHUB_TOKEN,
asset: path.resolve(path.join(__dirname, "..", "publish", jpl)),
name: jpl,
label: jpl,
uploadUrl: releaseResult.upload_url,
};

console.log("githubAsset");
await githubAsset(releaseAssetOptions);
}

async function main() {
dotenv.config();

if (
process.env.GITHUB_TOKEN === undefined ||
process.env.GITHUB_TOKEN === ""
) {
throw new Error("No GITHUB_TOKEN in env");
}
const argv = require("yargs").argv;

let type: string;
if (argv.upload) {
await createRelease();
process.exit(0);
} else if (argv.patch) type = "patch";
else if (argv.minor) type = "minor";
else if (argv.major) type = "major";
else throw new Error("--patch, --minor or --major not provided");

if (!(await nothingUncomitted())) {
throw new Error("Not a clean git status");
}

if ((await getBranch()) !== "develop") {
throw new Error("not in develop branch");
}

const info = await getInfo();
console.log(info);

const reproOptions: ReproOptions = {
owner: info.owner,
repo: info.repo,
token: process.env.GITHUB_TOKEN,
};
if (!(await checkAuth(reproOptions))) {
throw new Error("Github auth error");
}
console.log("Create release");
await runNpmVersion(type);
const versionNumber = require(path.resolve(
path.join(__dirname, "../package.json")
)).version;
const version = `v${versionNumber}`;
console.log("new version " + version);
await setPluginVersion(versionNumber);
await updateChangelog(versionNumber);

await execCommand(
"git add src/manifest.json CHANGELOG.md package-lock.json package.json"
);

await execCommand(`git commit -m "bump version ${versionNumber}"`);
await execCommand(`git checkout master`);
if ((await getBranch()) !== "master") {
throw new Error("not in master branch");
}

await execCommand(`git merge develop --no-ff`);
await execCommand(`git tag ${version}`);

console.log("Execute the following commands:");
console.log(`git push`);
console.log(`git push --tag`);
console.log(`npm publish`);
console.log(`npm run gitRelease`);
}

main().catch((error) => {
console.error("Fatal error");
console.error(error);
process.exit(1);
});
Loading

0 comments on commit 7f919e7

Please sign in to comment.