Skip to content

Commit

Permalink
BACKLOG-23502 : handle @jahia/javascript-modules-library without usin…
Browse files Browse the repository at this point in the history
…g yarn command, provide an empty yarn.lock (#71)
  • Loading branch information
dgriffon authored Jan 13, 2025
1 parent f161a6e commit 9929f7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import path from 'path';
import {fileURLToPath} from 'url';
import {replaceInFileSync} from 'replace-in-file';
import camelCase from 'camelcase';
import {execSync} from 'child_process';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -34,8 +33,6 @@ where

// First let's do some version checks
console.log('Node version detected:', process.versions.node);
const yarnVersion = execSync('yarn --version', {encoding: 'utf8'});
console.log('Yarn version:', yarnVersion);

// Create a project directory with the project name.
const currentDir = process.cwd();
Expand Down Expand Up @@ -130,11 +127,8 @@ fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms'), {recursi
fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'forms'), {recursive: true});
fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'fieldsets'), {recursive: true});

// Add the latest @jahia/javascript-modules-library
execSync('yarn add @jahia/javascript-modules-library', {cwd: projectDir});
const javascriptModulesLibraryInfo = execSync('yarn info @jahia/javascript-modules-library version --json', {cwd: projectDir, encoding: 'utf8'});
const javascriptModulesLibraryInfoValue = JSON.parse(javascriptModulesLibraryInfo).value;
console.log(`Added ${javascriptModulesLibraryInfoValue} to the project`);
// Add an empty yarn.lock in case any parent folder is using yarn
fs.writeFileSync(path.join(projectDir, 'yarn.lock'), '', 'utf8');

console.log(`Created \x1B[1m${projectName}\x1B[0m at \x1B[1m${projectDir}\x1B[0m`);
console.log('Success! Your new project is ready.');
Expand Down
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"static-resources": "/icons,/images,/javascript,/locales"
},
"dependencies": {
"@jahia/javascript-modules-library": "0.x || ^1.0.0",
"graphql": "^16.7.1",
"i18next": "^23.10.1",
"react": "^18.2.0",
Expand Down
3 changes: 2 additions & 1 deletion tests/create-templatesSet-project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ describe('npx @jahia/create-module', () => {
'static/javascript',
'settings/configurations',
'settings/content-editor-forms/forms',
'settings/content-editor-forms/fieldsets'
'settings/content-editor-forms/fieldsets',
'yarn.lock'
];
if (moduleType === 'templatesSet') {
// This file should only exist for templates set
Expand Down

0 comments on commit 9929f7a

Please sign in to comment.