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