You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-06 09:19:22 +02:00
Plugins: Add support for JPL archive format
This commit is contained in:
@@ -9,10 +9,15 @@ module.exports = class extends Generator {
|
||||
this.log(yosay(`Welcome to the fine ${chalk.red('generator-joplin')} generator!`));
|
||||
|
||||
const prompts = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'pluginId',
|
||||
message: 'Plugin ID [Must be a globally unique ID such as "com.example.MyPlugin" or a UUID]',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'pluginName',
|
||||
message: 'Plugin name:',
|
||||
message: 'Plugin name [User-friendly string which will be displayed in UI]',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
dist/*
|
||||
node_modules/
|
||||
node_modules/
|
||||
*.jpl
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "joplin_plugin",
|
||||
"name": "<%= pluginId %>",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
@@ -12,6 +12,10 @@
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.14",
|
||||
"copy-webpack-plugin": "^6.1.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"glob": "^7.1.6",
|
||||
"on-build-webpack": "^0.1.0",
|
||||
"tar": "^6.0.5",
|
||||
"ts-loader": "^7.0.5",
|
||||
"typescript": "^3.9.3",
|
||||
"webpack": "^4.43.0",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"id": "<%= pluginId %>",
|
||||
"app_min_version": "1.4",
|
||||
"version": "1.0.0",
|
||||
"name": "<%= pluginName %>",
|
||||
"description": "<%= pluginDescription %>",
|
||||
"version": "1.0.0",
|
||||
"author": "<%= pluginAuthor %>",
|
||||
"homepage_url": "<%= pluginHomepageUrl %>",
|
||||
"app_min_version": "1.4"
|
||||
"homepage_url": "<%= pluginHomepageUrl %>"
|
||||
}
|
||||
@@ -1,5 +1,42 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const WebpackOnBuildPlugin = require('on-build-webpack');
|
||||
const tar = require('tar');
|
||||
const glob = require('glob');
|
||||
|
||||
function readManifest(manifestPath) {
|
||||
const content = fs.readFileSync(manifestPath, 'utf8');
|
||||
const output = JSON.parse(content);
|
||||
if (!output.id) throw new Error(`Manifest plugin ID is not set in ${manifestPath}`);
|
||||
return output;
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
fs.removeSync(destPath);
|
||||
|
||||
tar.create(
|
||||
{
|
||||
strict: true,
|
||||
portable: true,
|
||||
file: destPath,
|
||||
cwd: sourceDir,
|
||||
sync: true,
|
||||
},
|
||||
distFiles
|
||||
);
|
||||
|
||||
console.info(`Plugin archive has been created in ${destPath}`);
|
||||
}
|
||||
|
||||
const distDir = path.resolve(__dirname, 'dist');
|
||||
const srcDir = path.resolve(__dirname, 'src');
|
||||
const manifestPath = `${srcDir}/manifest.json`;
|
||||
const manifest = readManifest(manifestPath);
|
||||
const archiveFilePath = path.resolve(__dirname, `${manifest.id}.jpl`);
|
||||
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
@@ -22,7 +59,7 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
filename: 'index.js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
path: distDir,
|
||||
},
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
@@ -40,5 +77,8 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
}),
|
||||
new WebpackOnBuildPlugin(function() {
|
||||
createPluginArchive(distDir, archiveFilePath);
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
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.0.17",
|
||||
"version": "1.4.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "1.0.17",
|
||||
"version": "1.4.0",
|
||||
"description": "Scaffolds out a new Joplin plugin",
|
||||
"homepage": "https://joplinapp.org",
|
||||
"author": {
|
||||
@@ -19,8 +19,8 @@
|
||||
"npm": ">= 4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"yeoman-generator": "^2.0.1",
|
||||
"chalk": "^2.1.0",
|
||||
"yeoman-generator": "^2.0.1",
|
||||
"yosay": "^2.0.1"
|
||||
},
|
||||
"repository": "https://github.com/laurent22/generator-joplin",
|
||||
|
||||
Reference in New Issue
Block a user