@talend/scripts-config-cdn
Advanced tools
Comparing version 10.8.0 to 10.9.0
{ | ||
"root": true, | ||
"extends": "@talend" | ||
"extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:import/recommended"], | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"jasmine": true, | ||
"jest": true | ||
}, | ||
"parser": "@babel/eslint-parser", | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module", | ||
"requireConfigFile": false | ||
} | ||
} |
100
cdn.js
@@ -19,3 +19,6 @@ /* eslint-disable global-require */ | ||
function getModuleName(nameandversion) { | ||
function getModuleName(nameandversion, isPnpm = false) { | ||
if (isPnpm) { | ||
nameandversion = nameandversion.startsWith('/') ? nameandversion.substring(1) : nameandversion; | ||
} | ||
const split = nameandversion.split('@'); | ||
@@ -28,2 +31,13 @@ if (nameandversion.startsWith('@')) { | ||
function getModuleVersion(nameandversion, isPnpm = false) { | ||
if (isPnpm) { | ||
nameandversion = nameandversion.startsWith('/') ? nameandversion.substring(1) : nameandversion; | ||
} | ||
const split = nameandversion.split('@'); | ||
if (nameandversion.startsWith('@')) { | ||
return split[2]; | ||
} | ||
return split[1]; | ||
} | ||
function addToCopyConfig(info, config) { | ||
@@ -114,37 +128,61 @@ if (info && info.local) { | ||
const cwd = dir || process.cwd(); | ||
const lockTypeMap = { | ||
npm: { | ||
lockfile: 'package-lock.json', | ||
path: path.join(cwd, 'package-lock.json'), | ||
}, | ||
yarn: { | ||
lockfile: 'yarn.lock', | ||
path: path.join(cwd, 'yarn.lock'), | ||
}, | ||
pnpm: { | ||
lockfile: 'pnpm-lock.yaml', | ||
path: path.join(cwd, 'pnpm-lock.yaml'), | ||
}, | ||
}; | ||
let infos = []; | ||
let lockType = 'package-lock.json'; | ||
let lockPath = path.join(cwd, lockType); | ||
if (fs.existsSync(lockPath)) { | ||
const packagelock = require(lockPath); | ||
if (fs.existsSync(lockTypeMap.npm.path)) { | ||
const packagelock = require(lockTypeMap.npm.lockfile); | ||
infos = getAllFlattenDependencies(packagelock) | ||
.map(({ name, version }) => moduleToCdn(name, version, { env: 'development' })) | ||
.map(addLocal); | ||
} else if (fs.existsSync(lockTypeMap.yarn.path)) { | ||
const { path: lockPath } = lockTypeMap.yarn; | ||
let yarnv1; | ||
let yarnv3; | ||
try { | ||
yarnv1 = lockfile.parse(fs.readFileSync(lockPath, 'utf-8')); | ||
} catch (e) { | ||
yarnv3 = yaml.load(fs.readFileSync(lockPath, 'utf-8')); | ||
// eslint-disable-next-line no-underscore-dangle | ||
delete yarnv3.__metadata; | ||
} | ||
const json = yarnv1 ? yarnv1.object : yarnv3; | ||
infos = Object.keys(json) | ||
.map(moduleAndversion => { | ||
const moduleName = getModuleName(moduleAndversion); | ||
return moduleToCdn(moduleName, json[moduleAndversion].version, { | ||
env: 'development', | ||
}); | ||
}) | ||
.map(addLocal); | ||
} else if (fs.existsSync(lockTypeMap.pnpm.path)) { | ||
const json = yaml.load(fs.readFileSync(lockTypeMap.pnpm.path, 'utf-8')); | ||
infos = Object.keys(json.packages) | ||
.map(moduleAndversion => { | ||
if (moduleAndversion.startsWith('file:')) { | ||
return null; | ||
} | ||
const moduleName = getModuleName(moduleAndversion, true); | ||
return moduleToCdn(moduleName, getModuleVersion(moduleAndversion, true), { | ||
env: 'development', | ||
}); | ||
}) | ||
.map(addLocal); | ||
console.log('pnpm lock file found'); | ||
} else { | ||
lockType = 'yarn.lock'; | ||
lockPath = path.join(cwd, lockType); | ||
if (fs.existsSync(lockPath)) { | ||
let yarnv1; | ||
let yarnv3; | ||
try { | ||
yarnv1 = lockfile.parse(fs.readFileSync(lockPath, 'utf-8')); | ||
} catch (e) { | ||
yarnv3 = yaml.load(fs.readFileSync(lockPath, 'utf-8')); | ||
// eslint-disable-next-line no-underscore-dangle | ||
delete yarnv3.__metadata; | ||
} | ||
const json = yarnv1 ? yarnv1.object : yarnv3; | ||
infos = Object.keys(json) | ||
.map(moduleAndversion => { | ||
const moduleName = getModuleName(moduleAndversion); | ||
return moduleToCdn(moduleName, json[moduleAndversion].version, { | ||
env: 'development', | ||
}); | ||
}) | ||
.map(addLocal); | ||
} else { | ||
console.log(`No lockfile found in ${cwd}. Search in parent directory`); | ||
return getModulesFromLockFile(path.join(cwd, '..')); | ||
} | ||
console.log(`No lockfile found in ${cwd}. Search in parent directory`); | ||
return getModulesFromLockFile(path.join(cwd, '..')); | ||
} | ||
@@ -151,0 +189,0 @@ return infos; |
# CHANGELOG | ||
## 10.9.0 | ||
### Minor Changes | ||
- 673984929: Add missing deps, adapt cdn code for pnpm and fix eslint config (circular dependency) | ||
## 10.8.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@talend/scripts-config-cdn", | ||
"version": "10.8.0", | ||
"version": "10.9.0", | ||
"description": "Provide a simple API to inject CDN config into existing webpack configuration", | ||
"main": "cdn.js", | ||
"scripts": { | ||
"lint": "talend-scripts lint ./", | ||
"lint": "eslint ./", | ||
"test": "echo \"Nothing to test\"" | ||
@@ -14,3 +14,3 @@ }, | ||
"@talend/dynamic-cdn-webpack-plugin": "^13.0.1", | ||
"@talend/module-to-cdn": "^9.9.1", | ||
"@talend/module-to-cdn": "^9.10.0", | ||
"@yarnpkg/lockfile": "^1.1.0", | ||
@@ -20,2 +20,6 @@ "js-yaml": "^3.14.1", | ||
}, | ||
"devDependencies": { | ||
"@babel/eslint-parser": "^7.23.3", | ||
"eslint": "^8.53.0" | ||
}, | ||
"publishConfig": { | ||
@@ -22,0 +26,0 @@ "access": "public" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38184
1148
2