@plumeria/compiler 0.6.1 → 0.6.3
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.
- package/bin/css.mjs +13 -9
- package/package.json +5 -6
- package/src/index.ts +21 -9
- package/src/clean-up.ts +0 -17
- package/tsconfig.json +0 -6
package/bin/css.mjs
CHANGED
|
@@ -5,28 +5,30 @@ import path from 'path';
|
|
|
5
5
|
import { styleText } from 'util';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
|
|
8
|
-
const checkMark = styleText('greenBright', '✓');
|
|
9
|
-
|
|
10
8
|
try {
|
|
9
|
+
process.env.PATH = `${path.resolve(process.cwd(), 'node_modules', '.bin')}:${process.env.PATH}`;
|
|
10
|
+
const checkMark = styleText('greenBright', '✓');
|
|
11
11
|
const isPnpm = fs.existsSync(path.join(process.cwd(), 'node_modules/.pnpm'));
|
|
12
|
-
|
|
13
12
|
const typecheck = process.argv.includes('--type-check');
|
|
13
|
+
|
|
14
14
|
if (typecheck)
|
|
15
|
-
execSync('
|
|
15
|
+
execSync('tsc --noEmit --incremental false', {
|
|
16
16
|
stdio: 'inherit',
|
|
17
17
|
cwd: process.cwd(),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const plumeriaPath = isPnpm
|
|
20
|
+
const plumeriaPath = isPnpm
|
|
21
|
+
? findPnpmPlumeriaPath()
|
|
22
|
+
: path.join(process.cwd(), 'node_modules/@plumeria');
|
|
21
23
|
|
|
22
24
|
const argv = process.argv.includes('--log') ? ' --log' : '';
|
|
23
|
-
execSync('
|
|
25
|
+
execSync('rscute compiler/src/index.ts' + argv, {
|
|
24
26
|
stdio: 'inherit',
|
|
25
27
|
cwd: plumeriaPath,
|
|
26
28
|
});
|
|
27
29
|
|
|
28
|
-
const
|
|
29
|
-
console.log(` ${checkMark} Compiled... ${
|
|
30
|
+
const compilation = typecheck ? 'Type-check completed' : '';
|
|
31
|
+
console.log(` ${checkMark} Compiled... ${compilation}`);
|
|
30
32
|
} catch (error) {
|
|
31
33
|
console.error('Compilation failed:', error.message);
|
|
32
34
|
process.exit(1);
|
|
@@ -34,7 +36,9 @@ try {
|
|
|
34
36
|
|
|
35
37
|
function findPnpmPlumeriaPath() {
|
|
36
38
|
const pnpmPath = path.join(process.cwd(), 'node_modules/.pnpm');
|
|
37
|
-
const plumeriaDir = fs
|
|
39
|
+
const plumeriaDir = fs
|
|
40
|
+
.readdirSync(pnpmPath)
|
|
41
|
+
.find((dir) => dir.startsWith('@plumeria+compiler@'));
|
|
38
42
|
|
|
39
43
|
if (!plumeriaDir) {
|
|
40
44
|
throw new Error('Could not find @plumeria package in pnpm directory');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Compiler for Plumeria that build and optimizes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -13,22 +13,21 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"files": [
|
|
15
15
|
"bin",
|
|
16
|
-
"src"
|
|
17
|
-
"tsconfig.json"
|
|
16
|
+
"src"
|
|
18
17
|
],
|
|
19
18
|
"bin": {
|
|
20
19
|
"css": "./bin/css.mjs"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"fast-glob": "^3.3.3",
|
|
23
|
+
"rscute": "^0.0.1",
|
|
24
24
|
"postcss": "^8.4.49",
|
|
25
|
-
"postcss-combine-duplicated-selectors": "^10.0.3"
|
|
26
|
-
"tsx": "^4.19.2"
|
|
25
|
+
"postcss-combine-duplicated-selectors": "^10.0.3"
|
|
27
26
|
},
|
|
28
27
|
"publishConfig": {
|
|
29
28
|
"access": "public"
|
|
30
29
|
},
|
|
31
30
|
"scripts": {
|
|
32
|
-
"build": "echo '
|
|
31
|
+
"build": "echo 'Build unnecessary'"
|
|
33
32
|
}
|
|
34
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
1
2
|
import * as path from 'path';
|
|
2
3
|
import * as fs from 'fs';
|
|
4
|
+
import { execute } from 'rscute';
|
|
3
5
|
import ts from 'typescript';
|
|
4
6
|
import fg from 'fast-glob';
|
|
5
|
-
import { cleanUp } from './clean-up';
|
|
6
7
|
import { buildCreate } from '@plumeria/core/dist/method/create-build-helper';
|
|
7
8
|
import { buildGlobal } from '@plumeria/core/dist/method/global-build-helper';
|
|
8
9
|
import postcss from 'postcss';
|
|
9
10
|
import combineSelectors from 'postcss-combine-duplicated-selectors';
|
|
10
11
|
|
|
12
|
+
export const cleanUp = async () => {
|
|
13
|
+
const projectRoot = process.cwd().split('node_modules')[0];
|
|
14
|
+
const directPath = path.join(projectRoot, 'node_modules/@plumeria/core');
|
|
15
|
+
const coreFilePath = path.join(directPath, 'stylesheet/core.css');
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
fs.writeFileSync(coreFilePath, '', 'utf-8');
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.error('An error occurred:', err);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
11
24
|
function isCSS(filePath: string): boolean {
|
|
12
25
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
13
26
|
const sourceFile = ts.createSourceFile(
|
|
@@ -39,8 +52,9 @@ async function getAppRoot(): Promise<string> {
|
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
async function optimizeCSS() {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
55
|
+
const corePackagePath = import.meta.resolve('@plumeria/core/package.json');
|
|
56
|
+
const corePath = path.dirname(fileURLToPath(new URL(corePackagePath)));
|
|
57
|
+
const cssPath = path.join(corePath, 'stylesheet/core.css');
|
|
44
58
|
const cssContent = fs.readFileSync(cssPath, 'utf8');
|
|
45
59
|
const result = postcss([
|
|
46
60
|
combineSelectors({ removeDuplicatedProperties: true }),
|
|
@@ -63,16 +77,14 @@ async function optimizeCSS() {
|
|
|
63
77
|
],
|
|
64
78
|
});
|
|
65
79
|
const styleFiles = files.filter(isCSS);
|
|
66
|
-
const importPromises = styleFiles.map(
|
|
67
|
-
(styleFile) => import(path.resolve(styleFile)),
|
|
68
|
-
);
|
|
69
|
-
await Promise.all(importPromises);
|
|
70
|
-
|
|
71
80
|
for (let i = 0; i < styleFiles.length; i++) {
|
|
72
|
-
await
|
|
81
|
+
await execute(path.resolve(styleFiles[i]));
|
|
73
82
|
}
|
|
74
83
|
for (let i = 0; i < styleFiles.length; i++) {
|
|
75
84
|
await buildGlobal();
|
|
76
85
|
}
|
|
86
|
+
for (let i = 0; i < styleFiles.length; i++) {
|
|
87
|
+
await buildCreate();
|
|
88
|
+
}
|
|
77
89
|
await optimizeCSS();
|
|
78
90
|
})();
|
package/src/clean-up.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
export const cleanUp = async () => {
|
|
5
|
-
const projectRoot = process.cwd().split('node_modules')[0];
|
|
6
|
-
const directPath = path.join(projectRoot, 'node_modules/@plumeria/core');
|
|
7
|
-
|
|
8
|
-
const createFilePath = directPath + '/dist/styles/create.css';
|
|
9
|
-
const globalFilePath = directPath + '/dist/styles/global.css';
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
writeFileSync(createFilePath, '', 'utf-8');
|
|
13
|
-
writeFileSync(globalFilePath, '', 'utf-8');
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.error('An error occurred:', err);
|
|
16
|
-
}
|
|
17
|
-
};
|