@lls/vitescripts 2.0.22 → 23.0.0-abcd
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/package.json +13 -14
- package/src/esbuildCssModulePlugin.mjs +1 -1
- package/src/index.mjs +1 -0
- package/src/llsAssetsPlugin.mjs +17 -0
- package/src/postBuildTsTypes.mjs +36 -0
package/package.json
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/vitescripts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0-abcd",
|
|
4
4
|
"description": "lls vite plugins",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/"
|
|
8
8
|
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "CONF_ENV=test npx vitest run",
|
|
11
|
-
"postinstall": "test \"$INIT_CWD\" = \"$PWD\" && npx husky install || echo 'Skipping postinstall'"
|
|
12
|
-
},
|
|
13
9
|
"dependencies": {
|
|
14
|
-
"
|
|
10
|
+
"browserslist": "4.22.1",
|
|
15
11
|
"esbuild-plugin-lightningcss-modules": "0.1.1",
|
|
16
|
-
"
|
|
12
|
+
"lightningcss": "1.22.1"
|
|
17
13
|
},
|
|
18
14
|
"type": "module",
|
|
19
15
|
"author": "",
|
|
20
16
|
"license": "ISC",
|
|
21
17
|
"devDependencies": {
|
|
22
|
-
"@lls/
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"vitest": "0.34.6"
|
|
18
|
+
"@lls/lls-kit": "23.0.0",
|
|
19
|
+
"nano-staged": "0.8.0",
|
|
20
|
+
"vitest": "1.0.4"
|
|
26
21
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
22
|
+
"nano-staged": {
|
|
23
|
+
"*.{js,jsx,mjs,tsx,ts}": "CONF_ENV=test pnpm vitest related --run"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "CONF_ENV=test pnpm vitest run",
|
|
27
|
+
"precommit": "pnpm nano-staged"
|
|
29
28
|
}
|
|
30
|
-
}
|
|
29
|
+
}
|
|
@@ -23,9 +23,9 @@ export default ({ prefix = '', llsCssModuleMacroPluginArg }) => {
|
|
|
23
23
|
})
|
|
24
24
|
build.onLoad({ filter: /module\.css$/ }, async args => {
|
|
25
25
|
if (args.path.startsWith(tmpDir)) return
|
|
26
|
+
|
|
26
27
|
const contents = await fs.promises.readFile(args.path, 'utf8').then(str => llsCssModuleMacroPluginInstance.transform(str, args.path))
|
|
27
28
|
const id = args.path.replace(process.cwd(), '').replace(/\//g, '_')
|
|
28
|
-
|
|
29
29
|
const out = path.join(tmpDir, id)
|
|
30
30
|
await fs.promises.writeFile(out, contents)
|
|
31
31
|
return {
|
package/src/index.mjs
CHANGED
|
@@ -8,3 +8,4 @@ export { default as llsLadlePlugin } from './llsLadlePlugin.mjs'
|
|
|
8
8
|
export { default as llsCssModuleMacroPlugin } from './llsCssModuleMacroPlugin.mjs'
|
|
9
9
|
export { default as postBuildAutoprefixerPlugin } from './postBuildAutoprefixerPlugin.mjs'
|
|
10
10
|
export { default as esbuildCssModulePlugin } from './esbuildCssModulePlugin.mjs'
|
|
11
|
+
export { default as postBuildTsTypesPlugin } from './postBuildTsTypes.mjs'
|
package/src/llsAssetsPlugin.mjs
CHANGED
|
@@ -21,8 +21,25 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets', { stripRoot = true
|
|
|
21
21
|
name: 'lls:copyassets',
|
|
22
22
|
async config () {
|
|
23
23
|
await execP(`mkdir -p ${publicAssetDir}`)
|
|
24
|
+
const pnpmNameToPath = await execP('pnpm ls -r @lls/lls-drawer --json'/*'pnpm ls -r -d 0 --json'*/)
|
|
25
|
+
.then(({ stdout }) => JSON.parse(stdout))
|
|
26
|
+
.then(json => {
|
|
27
|
+
let drawer = null
|
|
28
|
+
const back = json.map(({ name, path, dependencies }) => {
|
|
29
|
+
if (dependencies?.['@lls/lls-drawer']?.path) {
|
|
30
|
+
drawer = ['@lls/lls-drawer', dependencies?.['@lls/lls-drawer']?.path + '/lib/assets/*']
|
|
31
|
+
}
|
|
32
|
+
return [name, path + '/lib/assets/*']
|
|
33
|
+
})
|
|
34
|
+
return back.concat(drawer ? [drawer] : [])
|
|
35
|
+
})
|
|
36
|
+
.then(Object.fromEntries)
|
|
37
|
+
.catch(e => {})
|
|
24
38
|
const repoArgs = await Promise.all(llsRepos.map(async repo => {
|
|
25
39
|
if (!repo.startsWith('@')) return repo
|
|
40
|
+
const pnpmPath = pnpmNameToPath[repo]
|
|
41
|
+
if (pnpmPath) return pnpmPath
|
|
42
|
+
|
|
26
43
|
const aPath = 'lib/assets/*'
|
|
27
44
|
const prefix = await fileExists(`${process.cwd()}/node_modules/${repo}`)
|
|
28
45
|
? `${process.cwd()}/node_modules/${repo}`
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'node:fs/promises'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { exec } from 'child_process'
|
|
4
|
+
import util from 'util'
|
|
5
|
+
const execp = util.promisify(exec)
|
|
6
|
+
|
|
7
|
+
const getDirectoryFileNames = async directory => {
|
|
8
|
+
const fileNames = []
|
|
9
|
+
const filesInDirectory = await fs.readdir(directory)
|
|
10
|
+
for (const fileName of filesInDirectory) {
|
|
11
|
+
const absolute = path.join(directory, fileName)
|
|
12
|
+
if ((await fs.stat(absolute)).isDirectory()) {
|
|
13
|
+
fileNames.push(...await getDirectoryFileNames(absolute))
|
|
14
|
+
} else {
|
|
15
|
+
fileNames.push(absolute)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return fileNames
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const postBuildTstypes = async ({ rootAliases = [] }) => {
|
|
22
|
+
try {
|
|
23
|
+
await fs.access('./builttypes', fs.constants.F_OK)
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const fileNames = await getDirectoryFileNames('./builttypes')
|
|
28
|
+
const rootAliasRegex = new RegExp(rootAliases.map(x => x + '/').join('|') || 'nevermatching/', 'g')
|
|
29
|
+
for (const fileName of fileNames) {
|
|
30
|
+
await fs.readFile(fileName, 'utf8').then(
|
|
31
|
+
str => str.replaceAll(rootAliasRegex, `${path.relative(fileName, 'builttypes').slice(1)}/`) // builttypes/index.ts will be resolved to '..' so we always remove the first dot
|
|
32
|
+
).then(outStr => fs.writeFile(fileName, outStr))
|
|
33
|
+
}
|
|
34
|
+
await execp('cp -r builttypes/. lib')
|
|
35
|
+
}
|
|
36
|
+
export default postBuildTstypes
|