argon-clientlibs
Advanced tools
Comparing version 0.1.1 to 0.2.0
const clientlibDist = `apps/settings/wcm/designs`; | ||
const projectName = `argonui`; | ||
const projectName = `argon`; | ||
module.exports = { | ||
@@ -7,12 +7,4 @@ jcrRoot: 'dist/jcr_root', | ||
clientlibs: { | ||
vendor: { | ||
categories: ['argonui.vendor'], | ||
basePath: `${clientlibDist}/${projectName}/clientlibs/vendor.publish`, | ||
dependencies: ['granite.jquery'], | ||
paths: [ | ||
`${clientlibDist}/${projectName}/clientlibs/vendor.publish` | ||
] | ||
}, | ||
global: { | ||
categories: ['argonui.global'], | ||
categories: ['argon.global'], | ||
jsProcessor: [ | ||
@@ -26,4 +18,6 @@ 'min:gcc', | ||
paths: [ | ||
`${clientlibDist}/${projectName}/clientlibs/global.publish`, | ||
`${clientlibDist}/${projectName}/clientlibs/common.publish`, | ||
`!testDirectory/js`, | ||
`!testDirectory/css/ignored`, | ||
`testDirectory/js`, | ||
`testDirectory/css`, | ||
] | ||
@@ -30,0 +24,0 @@ } |
57
index.js
@@ -7,2 +7,5 @@ #!/usr/bin/env node | ||
const argv = require('yargs').argv; | ||
const ignoredPaths = []; | ||
try { | ||
@@ -25,25 +28,34 @@ const configFile = argv.config || 'argon.config.js'; | ||
const clientlibsConfig = argonuiConfig.clientlibs; | ||
function testIgnoredPaths(path) { | ||
let result = false; | ||
ignoredPaths.forEach(ignoredPath => { | ||
result = result || path.includes(ignoredPath.substring(1)) | ||
}); | ||
return result; | ||
} | ||
// Recursive function to scan and create respective js and css text files | ||
function recTestFiles(testPath, targetPath) { | ||
if (fs.existsSync(testPath)) { | ||
const fileStat = fs.lstatSync(testPath); | ||
if (fileStat.isFile()) { | ||
const matches = testPath.match(/\.(js|css|less)$/); | ||
if (matches && matches.length && matches[1]) { | ||
const ext = matches[1] === 'less' ? 'css' : matches[1]; | ||
const fileName = `${ext}.txt`; | ||
fs[ | ||
!fs.existsSync(`${targetPath}/${fileName}`) | ||
? 'writeFileSync' | ||
: 'appendFileSync' | ||
](`${targetPath}/${fileName}`, `${rpath.relative(targetPath, testPath).replace(/[\\]/g, '/')}\n`); | ||
if (!testIgnoredPaths(testPath)) { | ||
const fileStat = fs.lstatSync(testPath); | ||
if (fileStat.isFile()) { | ||
const matches = testPath.match(/\.(js|css|less)$/); | ||
if (matches && matches.length && matches[1]) { | ||
const ext = matches[1] === 'less' ? 'css' : matches[1]; | ||
const fileName = `${ext}.txt`; | ||
fs[ | ||
!fs.existsSync(`${targetPath}/${fileName}`) | ||
? 'writeFileSync' | ||
: 'appendFileSync' | ||
](`${targetPath}/${fileName}`, `${rpath.relative(targetPath, testPath).replace(/[\\]/g, '/')}\n`); | ||
} | ||
} | ||
} | ||
if (fileStat.isDirectory()) { | ||
// Recursively scan directory | ||
const files = fs.readdirSync(testPath); | ||
if (files.length) { | ||
files.forEach(file => { | ||
recTestFiles(`${testPath}/${file}`, targetPath); | ||
}); | ||
if (fileStat.isDirectory()) { | ||
// Recursively scan directory | ||
const files = fs.readdirSync(testPath); | ||
if (files.length) { | ||
files.forEach(file => { | ||
recTestFiles(`${testPath}/${file}`, targetPath); | ||
}); | ||
} | ||
} | ||
@@ -56,2 +68,3 @@ } | ||
Object.keys(clientlibsConfig).forEach(clientlib => { | ||
ignoredPaths.length = 0; | ||
const currentConfig = clientlibsConfig[clientlib]; | ||
@@ -94,3 +107,7 @@ const { basePath, categories = [], jsProcessor = [], cssProcessor = [], paths = [], dependencies = [] } = currentConfig; | ||
paths.forEach(path => { | ||
recTestFiles(`${distFolder}/${path}`, targetPath); | ||
if (path.startsWith('!')) { | ||
ignoredPaths.push(path); | ||
} else { | ||
recTestFiles(`${distFolder}/${path}`, targetPath); | ||
} | ||
}); | ||
@@ -97,0 +114,0 @@ console.log(colors.green(`Created client library with categories "${colors.bold(categories.join(','))}"`)); |
{ | ||
"name": "argon-clientlibs", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Argon UI clientlib is a helper package for Argon UI that converts regular JS or CSS package to a clientlib", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,10 +0,10 @@ | ||
# ArgonUI-clientlibs | ||
Converts a regular javascript or css package to an AEM client library | ||
# Argon clientlibs | ||
Converts a regular JS or CSS package to an AEM client library | ||
# Install | ||
```sh | ||
npm install --save-dev argonui-clientlibs | ||
npm install --save-dev argon-clientlibs | ||
``` | ||
This package is part of <a href="https://www.npmjs.com/package/argonui">ArgonUI Boilerplate</a>. However, it can function independently based on your project needs. | ||
This package works with <a href="https://www.npmjs.com/package/argon">Argon Framework</a>. It works independently if you look a little further. | ||
@@ -54,3 +54,3 @@ # How does it work? | ||
```sh | ||
npx create-clientlib --config=someOtherFileName.config.js | ||
``` | ||
npx create-clientlib --config=someOtherConfig.js | ||
``` |
9714
5
145
56