Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# production
/build

# node version manager
/.nvmrc

# misc
.DS_Store
.env.local
Expand All @@ -24,6 +27,3 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# plugin-zip
/plugin-zip
1 change: 1 addition & 0 deletions .nvmrc.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.20.0
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@
"react-select": "^3.1.0",
"reactstrap": "^8.4.1"
},
"engines": {
"node": "12.20.0",
"npm": "6.14.8"
},
"scripts": {
"clean": "rm -rf plugin-zip && mkdir plugin-zip",
"clean": "git clean -fdxq -- ./plugin-zip/",
"start": "npm run fix && node scripts/start.js",
"build": "export CI=\"${CI-true}\" && npm run fix && CI=true npm run test && node scripts/build.js",
"fix": "npm run translate && npm exec -- eslint --fix src/locale/lang",
"test": "node scripts/test.js",
"translate": "node scripts/translate.js",
"push-translate": "tx push -s",
"pull-translate": "tx pull -a -f && npm run translate",
"build-plugin": "export GENERATE_SOURCEMAP=false && npm run clean && npm run build && node scripts/build-plugin.js"
"build-plugin": "export GENERATE_SOURCEMAP=false && npm run build && node scripts/build-plugin.js"
},
"browserslist": {
"production": [
Expand Down
12 changes: 12 additions & 0 deletions plugin-zip/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# plugin-zip (build artefact folder)
#
# build output directory for the plugin zip archives
#
!/.gitignore

# zips
/*.zip

# zip backups
/*.zip~
/*.zip.~?*~
21 changes: 20 additions & 1 deletion scripts/build-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const config = {
dir: paths.appBuild + '/static/'
};

// verify zip output path against the file-system
const zipPathFromZipFile = (file) => path.join(paths.zipPath, file);
if (!fs.existsSync(zipPathFromZipFile('.'))) {
console.error(`fatal: paths.zipPath: '${paths.zipPath}' does not exists`);
process.exit(1);
}

const zip = new JSZip();

// build file
Expand Down Expand Up @@ -49,7 +56,19 @@ zip.file('task/info.json', JSON.stringify(jsonFileContent, null, ' '));

zip.generateAsync({type: 'nodebuffer'}).then(function(content) {
let zip = `${pluginInfoContent.name}-${pluginInfoContent.version}.zip`;
fs.writeFile(paths.zipPath + '/' + zip, content, function(err) {
{ /* do backups similar to cp(1) --backup=numbered */
const zipPath = zipPathFromZipFile(zip);
let number = 1;
let bakFile = zipPath + `.~${number}~`;
if (fs.existsSync(zipPath)) {
while (fs.existsSync(bakFile)) {
bakFile = zipPath + `.~${number++}~`;
}
console.log(`overwriting '${zip}' (backup: '${bakFile.replace(/^.*\/([^/]+)$/, '$1')}')`);
fs.renameSync(zipPath , bakFile);
}
}
fs.writeFile(zipPathFromZipFile(zip), content, function(err) {
if (err) {
console.log(zip + ' failed');
console.log(err);
Expand Down
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ import './setting';

ReactDOM.render(<App showDialog={true} key={(new Date()).getTime()} />, document.getElementById('root'));

/**
* plugin development window.app shim (dtable-ui)
*
* @link https://docs.seatable.io/published/dtable-sdk/dtable-ui.md
*/
window.app = window.app ? window.app : {};
window.app.expandRow = window.app.expandRow || ((row, rowTable) => {
console.log('dtable-ui shim: app.expandRow', [row, rowTable]);
});