Skip to content

Commit

Permalink
Try fixing bugs - 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Jan 20, 2022
1 parent bd1af5d commit 7adbf13
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `tw5-plugin-packer` will package the TiddlyWiki5 plugin folders you wrote in

### `source`

**Required(必填)** The root directory of your plugin. You can add multiple paths in the form of one per line. 你的插件的根目录。你可以以每行一个的形式添加多个路径
**Required(必填)** The root directory of your plugin. You can add multiple paths in the form of one per line, and **not to add quotation marks to each line**! 你的插件的根目录。你可以以每行一个的形式添加多个路径**注意每行不要加引号**

### `output`

Expand Down Expand Up @@ -73,7 +73,10 @@ The JSON file path of the successfully exported plugin, stored as an array of st
In the simplest case, pack one plugin at a time 最简单的情况,一次只打包一个插件:

```yaml
- uses: tiddly-gittly/tw5-plugin-packer@v0.0.5
# It's necessary to use checkout action to fetch your repo, or action cannot find your plugin files!
# 需要使用checkout action来获取项目,否则无法找到你的插件文件!
- uses: actions/checkout@v2
- uses: tiddly-gittly/tw5-plugin-packer@v0.0.6
with:
source: "src"
output: "dist"
Expand All @@ -82,7 +85,10 @@ In the simplest case, pack one plugin at a time 最简单的情况,一次只
You can also package multiple plugins at once 也可以一次打包多个插件:
```yaml
- uses: tiddly-gittly/tw5-plugin-packer@v0.0.5
# It's necessary to use checkout action to fetch your repo, or action cannot find your plugin files!
# 需要使用checkout action来获取项目,否则无法找到你的插件文件!
- uses: actions/checkout@v2
- uses: tiddly-gittly/tw5-plugin-packer@v0.0.6
with:
source: |
src1
Expand Down
13 changes: 0 additions & 13 deletions node_modules/tiddlywiki/boot/boot.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tw5-plugin-packer",
"version": "0.0.5-rc3",
"version": "0.0.6",
"description": "Pack up your tiddlywiki5 plugin to json file.",
"main": "packup.js",
"scripts": {
Expand Down
14 changes: 7 additions & 7 deletions packup.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ try {
console.log(` - Output: ${OUTPUT}`);
console.log(' - Input:');
SOURCE.forEach((plugin_source) => {
console.log(` - ${plugin_source}`);
console.log(` - ${plugin_source}`);
});
console.log(' - UglifyJSOption:');
console.log(UglifyJSOption);
Expand All @@ -59,10 +59,10 @@ try {
console.log(` - Packing up plugin ${plugin_source}.`);
const pluginInfo = tw.loadPluginFolder(plugin_source, undefined);
if (!pluginInfo || typeof pluginInfo.title !== 'string' || pluginInfo.title === '') {
console.log(` - Plugin is unavailable, dose it exist and has a plugin.info file?`);
console.log(` - Plugin is unavailable, dose it exist and has a plugin.info file?`);
return;
}
console.log(` - Plugin name is ${pluginInfo.title}.`);
console.log(` - Plugin name is ${pluginInfo.title}.`);
// Minify tiddlers
if (MINIFY) {
const tiddlersJson = JSON.parse(pluginInfo.text);
Expand All @@ -72,11 +72,11 @@ try {
const tiddler = tiddlersJson.tiddlers[tiddlers[i]];
try {
if (tiddler.type === 'application/javascript') {
console.log(` -Try minifying JS tiddler ${tiddlers[i]}.`);
console.log(` - Try minifying JS tiddler ${tiddlers[i]}.`);
const minified = UglifyJS.minify(tiddler.text, UglifyJSOption).code;
if (minified !== undefined) tiddler.text = minified;
} else if (tiddler.type === 'text/css') {
console.log(` -Try minifying CSS tiddler ${tiddlers[i]}.`);
console.log(` - Try minifying CSS tiddler ${tiddlers[i]}.`);
const minified = new CleanCSS(CleanCSSOptions).minify(tiddler.text).styles;
if (minified !== undefined) tiddler.text = minified;
}
Expand All @@ -88,11 +88,11 @@ try {
pluginInfo.text = JSON.stringify(tiddlersJson);
}
// Save JSON file
console.log(` - Saving plugin ${pluginInfo.title}.`);
console.log(` - Saving plugin ${pluginInfo.title}.`);
const fileName = path.basename(tw.utils.generateTiddlerFilepath(pluginInfo.title, {})) + '.json';
const filePath = path.join(OUTPUT, fileName);
fs.writeFileSync(filePath, JSON.stringify(pluginInfo));
console.log(` - Plugin ${pluginInfo.title} has been saved to ${filePath}.`);
console.log(` - Plugin ${pluginInfo.title} has been saved to ${filePath}.`);
successPlugins.push(filePath);
});
core.setOutput('output-plugins', successPlugins);
Expand Down

0 comments on commit 7adbf13

Please sign in to comment.