mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Generator: Fixed publish script
This commit is contained in:
parent
325a5ab08f
commit
f6d899eb29
@ -1,6 +1,7 @@
|
||||
const gulp = require('gulp');
|
||||
const fs = require('fs-extra');
|
||||
const utils = require('@joplin/tools/gulp/utils');
|
||||
const { setPackagePrivateField } = require('@joplin/tools/tool-utils');
|
||||
const tasks = {
|
||||
// compileExtensions: {
|
||||
// fn: require('../Tools/gulp/tasks/compileExtensions.js'),
|
||||
@ -10,12 +11,12 @@ const tasks = {
|
||||
// updateIgnoredTypeScriptBuild: require('../Tools/gulp/tasks/updateIgnoredTypeScriptBuild'),
|
||||
};
|
||||
|
||||
async function makePackagePublic(filePath) {
|
||||
const text = await fs.readFile(filePath, 'utf8');
|
||||
const obj = JSON.parse(text);
|
||||
delete obj.private;
|
||||
await fs.writeFile(filePath, JSON.stringify(obj), 'utf8');
|
||||
}
|
||||
// async function makePackagePublic(filePath) {
|
||||
// const text = await fs.readFile(filePath, 'utf8');
|
||||
// const obj = JSON.parse(text);
|
||||
// delete obj.private;
|
||||
// await fs.writeFile(filePath, JSON.stringify(obj), 'utf8');
|
||||
// }
|
||||
|
||||
tasks.prepareBuild = {
|
||||
fn: async () => {
|
||||
@ -25,7 +26,8 @@ tasks.prepareBuild = {
|
||||
});
|
||||
|
||||
await utils.copyFile(`${__dirname}/package.json`, `${buildDir}/package.json`);
|
||||
await makePackagePublic(`${buildDir}/package.json`);
|
||||
// await makePackagePublic(`${buildDir}/package.json`);
|
||||
await setPackagePrivateField(`${buildDir}/package.json`, false);
|
||||
|
||||
await utils.copyFile(`${__dirname}/package-lock.json`, `${buildDir}/package-lock.json`);
|
||||
await utils.copyFile(`${__dirname}/gulpfile.js`, `${buildDir}/gulpfile.js`);
|
||||
|
2
packages/generator-joplin/package-lock.json
generated
2
packages/generator-joplin/package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"description": "Scaffolds out a new Joplin plugin",
|
||||
"homepage": "https://joplinapp.org",
|
||||
"private": true,
|
||||
"author": {
|
||||
"name": "Laurent Cozic",
|
||||
"url": "https://joplinapp.org"
|
||||
@ -25,5 +24,6 @@
|
||||
"yosay": "^2.0.1"
|
||||
},
|
||||
"repository": "https://github.com/laurent22/generator-joplin",
|
||||
"license": "MIT"
|
||||
}
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
const { execCommand, execCommandVerbose, rootDir, gitPullTry } = require('./tool-utils.js');
|
||||
const { execCommand, execCommandVerbose, rootDir, gitPullTry, setPackagePrivateField } = require('./tool-utils.js');
|
||||
|
||||
const genDir = `${rootDir}/packages/generator-joplin`;
|
||||
|
||||
async function main() {
|
||||
process.chdir(genDir);
|
||||
|
||||
const packageFilePath = `${genDir}/package.json`;
|
||||
|
||||
console.info(`Running from: ${process.cwd()}`);
|
||||
|
||||
await gitPullTry();
|
||||
@ -12,15 +14,21 @@ async function main() {
|
||||
const version = (await execCommand('npm version patch')).trim();
|
||||
const tagName = `plugin-generator-${version}`;
|
||||
|
||||
console.info(`New version number: ${version}`);
|
||||
await setPackagePrivateField(packageFilePath, false);
|
||||
|
||||
await execCommandVerbose('npm', ['publish']);
|
||||
await gitPullTry();
|
||||
await execCommandVerbose('git', ['add', '-A']);
|
||||
await execCommandVerbose('git', ['commit', '-m', `Plugin Generator release ${version}`]);
|
||||
await execCommandVerbose('git', ['tag', tagName]);
|
||||
await execCommandVerbose('git', ['push']);
|
||||
await execCommandVerbose('git', ['push', '--tags']);
|
||||
try {
|
||||
console.info(`New version number: ${version}`);
|
||||
|
||||
await execCommandVerbose('npm', ['publish']);
|
||||
await gitPullTry();
|
||||
await execCommandVerbose('git', ['add', '-A']);
|
||||
await execCommandVerbose('git', ['commit', '-m', `Plugin Generator release ${version}`]);
|
||||
await execCommandVerbose('git', ['tag', tagName]);
|
||||
await execCommandVerbose('git', ['push']);
|
||||
await execCommandVerbose('git', ['push', '--tags']);
|
||||
} finally {
|
||||
await setPackagePrivateField(packageFilePath, true);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
@ -89,6 +89,17 @@ toolUtils.deleteLink = async function(path) {
|
||||
}
|
||||
};
|
||||
|
||||
toolUtils.setPackagePrivateField = async function(filePath, value) {
|
||||
const text = await fs.readFile(filePath, 'utf8');
|
||||
const obj = JSON.parse(text);
|
||||
if (!value) {
|
||||
delete obj.private;
|
||||
} else {
|
||||
obj.private = true;
|
||||
}
|
||||
await fs.writeFile(filePath, JSON.stringify(obj, null, 2), 'utf8');
|
||||
};
|
||||
|
||||
toolUtils.credentialDir = async function() {
|
||||
const username = require('os').userInfo().username;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user