Skip to content

Commit 0d63302

Browse files
authored
Release 5.0.0 (#40)
## Release notes * Improved copy command to replicate folder structures (#39) ### Release dependencies first In case of dependent Phovea/TDP repositories follow [dependency tree](https://wiki.datavisyn.io/phovea/fundamentals/development-process#dependency-hierarchy) from the top: ### 🏁 Finish line * [ ] Inform colleagues and customers about the release * [ ] Celebrate the new release 🥳
2 parents 18f5fba + 2256aaa commit 0d63302

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

bin/commands/copy.js

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
1-
const { call } = require('./utils');
1+
const glob = require('glob');
2+
const fs = require('fs-extra');
3+
const path = require('path');
24

35
module.exports = {
46
command: 'copy',
57
describe: 'Copy assets, styles, and static files to the dist folder',
68
handler: () => {
7-
call('shx', "--verbose cp -r src/assets/. dist/assets/ || echo 'no assets copied'");
8-
call('shx', "--verbose cp -R src/template/. dist/template/ || echo 'no template copied'");
9-
call('shx', "--verbose cp -R src/templates/. dist/templates/ || echo 'no templates copied'");
10-
call('shx', "--verbose cp -R src/scss/. dist/scss/ || echo 'no scss files copied'");
11-
call('shx', '--verbose cp "src/*.{txt,html,ejs,json}" dist/ || echo \'no file copied\'');
9+
const srcDir = 'src';
10+
const distDir = 'dist';
11+
// Files to copy
12+
const filePattern = '**/*.@(txt|html|ejs|json|md|scss|css|js|png|jpg|jpeg|gif|svg|ico|webmanifest|xml)';
13+
14+
// Additional folders to copy
15+
const additionalFolders = ['assets', 'template', 'templates', 'scss'];
16+
17+
// Copy specified folders from source to destination
18+
additionalFolders.forEach((folder) => {
19+
const srcFolderPath = path.join(srcDir, folder);
20+
21+
if (fs.existsSync(srcFolderPath)) {
22+
const distFolderPath = path.join(distDir, folder);
23+
24+
// Ensure the destination directory exists
25+
fs.ensureDirSync(distFolderPath);
26+
27+
// Copy the folder from source to destination
28+
fs.copySync(srcFolderPath, distFolderPath, { overwrite: true });
29+
console.log(`Copied ${srcFolderPath} to ${distFolderPath}`);
30+
}
31+
});
32+
33+
// Get a list of files matching the pattern
34+
const files = glob.sync(filePattern, { cwd: srcDir });
35+
files.forEach((file) => {
36+
const srcPath = path.join(srcDir, file);
37+
const distPath = path.join(distDir, file);
38+
39+
// Ensure the destination directory exists
40+
const distDirPath = path.dirname(distPath);
41+
fs.ensureDirSync(distDirPath);
42+
43+
// Copy the file from source to destination
44+
fs.copyFileSync(srcPath, distPath);
45+
console.log(`Copied ${srcPath} to ${distPath}`);
46+
});
1247
},
1348
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "visyn_scripts",
33
"description": "",
4-
"version": "4.1.0",
4+
"version": "5.0.0",
55
"author": {
66
"name": "datavisyn GmbH",
77
"email": "contact@datavisyn.io",

0 commit comments

Comments
 (0)