@digigov/cli-build-tailwind 0.9.0-navlist.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ {
2
+ "arg@4.1.3": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
3
+ "balanced-match@1.0.2": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
4
+ "brace-expansion@1.1.11": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
5
+ "buffer-from@1.1.2": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
6
+ "camelcase-css@2.0.1": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==",
7
+ "concat-map@0.0.1": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
8
+ "diff@4.0.2": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
9
+ "fs-extra@10.0.0": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
10
+ "fs.realpath@1.0.0": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
11
+ "glob@7.1.6": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
12
+ "graceful-fs@4.2.10": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
13
+ "inflight@1.0.6": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
14
+ "inherits@2.0.4": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
15
+ "jsonfile@6.1.0": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
16
+ "lilconfig@2.0.6": "sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==",
17
+ "make-error@1.3.6": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
18
+ "minimatch@3.1.2": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
19
+ "nanoid@3.3.4": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
20
+ "once@1.4.0": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
21
+ "path-is-absolute@1.0.1": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
22
+ "picocolors@1.0.0": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
23
+ "postcss-js@4.0.0_postcss@8.4.4": "sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==",
24
+ "postcss-load-config@3.1.4_postcss@8.4.4+ts-node@8.10.2": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==",
25
+ "postcss@8.4.4": "sha512-joU6fBsN6EIer28Lj6GDFoC/5yOZzLCfn0zHAn/MYXI7aPt4m4hK5KC5ovEZXy+lnCjmYIbQWngvju2ddyEr8Q==",
26
+ "source-map-js@1.0.2": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
27
+ "source-map-support@0.5.21": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
28
+ "source-map@0.6.1": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
29
+ "ts-node@8.10.2_typescript@4.2.3": "sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==",
30
+ "typescript@4.2.3": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
31
+ "universalify@2.0.0": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
32
+ "wrappy@1.0.2": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
33
+ "yaml@1.10.2": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
34
+ "yn@3.1.1": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q=="
35
+ }
package/build.js ADDED
@@ -0,0 +1,92 @@
1
+ const postcss = require('postcss');
2
+ const postcssrc = require('postcss-load-config');
3
+ const postcssJs = require('postcss-js');
4
+ const fs = require('fs-extra');
5
+ const path = require('path');
6
+ const glob = require('glob');
7
+
8
+
9
+ const buildDir = async (dir, file = 'index.css', cwd = process.cwd(), distFolder, replace) => {
10
+ process.env["DIGIGOV_CSS_BUILD"] = "TRUE";
11
+ const options = {
12
+ cwd,
13
+ options: {
14
+ map: {inline: true},
15
+ },
16
+ file: {
17
+ dirname: path.join(cwd, 'src', dir),
18
+ basename: file,
19
+ extname: '.css'
20
+ },
21
+ from: path.join(cwd, 'src', dir, file),
22
+ to: path.join(cwd, distFolder, dir, file),
23
+ };
24
+ const filePathPart = file === 'index.css' ? '' : `/${file.replace('.css', '')}`;
25
+ console.log(`Building ${dir} ${file}...`);
26
+ let css = fs.readFileSync(options.from, "utf8");
27
+ const rc = await postcssrc(options, path.join(cwd, 'src', dir))
28
+ .catch((err) => {
29
+ if(!err.message.includes('No PostCSS Config found')) throw err;
30
+ });
31
+ const result = await postcss(rc.plugins)
32
+ .process(css, options);
33
+ let processedCss = result.css;
34
+ let cssJs = JSON.stringify(postcssJs.objectify(result.root));
35
+ if(replace) {
36
+ for(const from in replace) {
37
+ const to = replace[from];
38
+ console.log(`Replace ${from} with ${to}`);
39
+ processedCss = processedCss.replaceAll(from, to);
40
+ cssJs = cssJs.replaceAll(from, to);
41
+ }
42
+ }
43
+ if(options.to) {
44
+ fs.outputFileSync(options.to, processedCss);
45
+ fs.outputFileSync(path.join(cwd, distFolder, `${dir}${filePathPart}.js`), `module.exports = ${cssJs}`);
46
+
47
+ } else process.stdout.write(processedCss, 'utf8');
48
+ return processedCss;
49
+ };
50
+
51
+
52
+ const build = async ({cwd = process.cwd(), distFolder = 'dist', allFiles = false, bundleFileName = 'index', replace}) => {
53
+ console.time('build');
54
+ console.log('All files:', allFiles,);
55
+ console.log(`Removing dist folder ${path.join(cwd, distFolder)}`);
56
+ fs.rmSync(path.join(cwd, distFolder), {
57
+ recursive: true, force: true
58
+ });
59
+ const subfolders = ['utilities', 'components', 'base'];
60
+ const cssParts = [];
61
+ for(const subfolder of subfolders) {
62
+ console.time(`build ${subfolder}`);
63
+ let css = '';
64
+ if(allFiles) {
65
+ for(const subpart of glob.sync(path.join(cwd, 'src', subfolder, "*.css"))) {
66
+ const fileName = path.basename(subpart);
67
+ if(fileName !== 'index.css') {
68
+ css += "\n" + await buildDir(subfolder, fileName, cwd, distFolder, replace);
69
+ } else {
70
+ await buildDir(subfolder, fileName, cwd, distFolder, replace);
71
+ }
72
+ }
73
+
74
+ } else {
75
+ css = await buildDir(subfolder, 'index.css', cwd, distFolder, replace);
76
+
77
+ }
78
+ cssParts.unshift(css);
79
+ console.timeEnd(`build ${subfolder}`);
80
+ }
81
+ fs.outputFileSync(path.join(cwd, `dist/${bundleFileName}.css`), cssParts.join('\n'));
82
+ console.timeEnd('build');
83
+ };
84
+ if(typeof require !== 'undefined' && require.main === module) {
85
+ build({});
86
+ }
87
+
88
+
89
+ module.exports = {
90
+ buildDir,
91
+ build
92
+ };
package/index.js ADDED
@@ -0,0 +1,28 @@
1
+ const {flags} = require('@oclif/command');
2
+ const {DigigovCommand} = require('@digigov/cli/lib');
3
+ const {build} = require('./build');
4
+ module.exports = class BuildTailwind extends DigigovCommand {
5
+ static description = 'build digigov libraries';
6
+ static id = 'build-tailwind';
7
+ dirname = __dirname;
8
+ static examples = [
9
+ `$ digigov build-tailwind`,
10
+ ];
11
+ static strict = true;
12
+ static flags = {
13
+ allFiles: flags.boolean({char: '--all-files'}),
14
+ bundle: flags.string({})
15
+ };
16
+ static load() {return BuildTailwind;}
17
+ async run() {
18
+ const {args, flags} = this.parse(BuildTailwind);
19
+ try {
20
+ await build({
21
+ bundleFileName: flags.bundle,
22
+ allFiles: flags.allFiles
23
+ });
24
+ } catch(err) {
25
+ console.log(err);
26
+ }
27
+ }
28
+ };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@digigov/cli-build-tailwind",
3
+ "version": "0.9.0-navlist.alpha.2",
4
+ "description": "Build tailwind plugin for Digigov CLI",
5
+ "main": "./index.js",
6
+ "author": "GRNET Devs <devs@lists.grnet.gr>",
7
+ "license": "BSD-2-Clause",
8
+ "private": false,
9
+ "dependencies": {
10
+ "fs-extra": "10.0.0",
11
+ "glob": "7.1.6",
12
+ "postcss": "8.4.4",
13
+ "postcss-js": "4.0.0",
14
+ "postcss-load-config": "3.1.4"
15
+ },
16
+ "peerDependencies": {
17
+ "@digigov/cli": "0.6.5-navlist.alpha.2"
18
+ },
19
+ "scripts": {}
20
+ }