diff --git a/setup/create-wp-project/readme.md b/setup/create-wp-project/readme.md index 605bec5ab..75ae8abd4 100644 --- a/setup/create-wp-project/readme.md +++ b/setup/create-wp-project/readme.md @@ -36,11 +36,14 @@ To make sure you use the latest version of npx command you can add `@latest` fla ## Specify version to create -If you want to specify a version of Eightshift Libs or Frontend Libs to use, you can use add two additional attributes to this command to specify a branch or release to use: +If you want to specify a version of Eightshift Libs, Frontend Libs or repository to use, you can use add two additional attributes to this command to specify a branch, release or repository to use: ``` +--eightshiftLibsRepo --eightshiftLibsBranch --eightshiftFrontendLibsBranch +--eightshiftFrontendLibsUrl + ``` Example: @@ -56,6 +59,18 @@ You can also specify the version of the create-wp-project script like this: npx create-wp-project@2.0.12 --eightshiftLibsBranch="release/6.0.0" --eightshiftFrontendLibsBranch="develop" ``` +You can also specify the repo of the create-wp-project script like this: + +``` +npx create-wp-project --eightshiftLibsRepo="https://github.com/example-repository/eightshift-libs.git" +``` + +You can also specify the repo of the create-wp-project script like this: + +``` +npx create-wp-project -eightshiftFrontendLibsBranch="develop" --eightshiftFrontendLibsRepoUrl="https://github.com/example-repository/eightshift-frontend-libs.git" +``` + ## Use a different repository diff --git a/setup/create-wp-project/src/arguments.js b/setup/create-wp-project/src/arguments.js index fb6ad295d..73e08c8b1 100644 --- a/setup/create-wp-project/src/arguments.js +++ b/setup/create-wp-project/src/arguments.js @@ -55,6 +55,13 @@ const scriptArguments = { type: 'text', skipPrompt: true, }, + eightshiftLibsRepo: { + name: 'eightshiftLibsRepo', + describe: 'Custom repository URL for the eightshift-libs (e.g., github.com/user/eightshift-libs).', + type: 'text', + default: 'infinum/eightshift-libs', // Setting default to ensure backward compatibility + skipPrompt: true, + }, eightshiftLibsBranch: { name: 'eightshiftLibsBranch', describe: 'Use this to override which infinum/eightshift-libs version is loaded (mainly used for testing).', @@ -67,6 +74,13 @@ const scriptArguments = { type: 'text', skipPrompt: true, }, + eightshiftFrontendLibsRepoUrl: { + name: 'eightshiftFrontendLibsRepoUrl', + describe: 'Custom repository URL for the eightshift-frontend-libs (e.g., github.com/user/eightshift-frontend-libs).', + type: 'text', + default: 'infinum/eightshift-frontend-libs', // Setting default to ensure backward compatibility + skipPrompt: true, + }, }; module.exports = { diff --git a/setup/create-wp-project/src/commands/theme.js b/setup/create-wp-project/src/commands/theme.js index a23b0f1c8..130a43eaf 100644 --- a/setup/create-wp-project/src/commands/theme.js +++ b/setup/create-wp-project/src/commands/theme.js @@ -65,7 +65,7 @@ exports.handler = async (argv) => { if (argv.eightshiftFrontendLibsBranch) { await installStep({ describe: `Installing Node packages`, - thisHappens: installModifiedNodeDependencies(projectPath, argv.eightshiftFrontendLibsBranch), + thisHappens: installModifiedNodeDependencies(projectPath, argv.eightshiftFrontendLibsBranch, argv.eightshiftFrontendLibsRepoUrl), }); } else { await installStep({ @@ -84,7 +84,7 @@ exports.handler = async (argv) => { if (argv.eightshiftLibsBranch) { await installStep({ describe: `Installing Composer packages`, - thisHappens: installModifiedComposerDependencies(projectPath, argv.eightshiftLibsBranch), + thisHappens: installModifiedComposerDependencies(projectPath, argv.eightshiftLibsBranch, argv.eightshiftLibsRepo), }); } else { await installStep({ diff --git a/setup/create-wp-project/src/dependencies.js b/setup/create-wp-project/src/dependencies.js index e1264c973..43d2f8e3d 100644 --- a/setup/create-wp-project/src/dependencies.js +++ b/setup/create-wp-project/src/dependencies.js @@ -1,18 +1,18 @@ const { installNodePackage, installComposerPackage } = require('./basics/command-line'); const eightshiftLibsName = ''; -const eightshiftLibsRepo = 'infinum/eightshift-libs'; +const defaultEightshiftLibsRepo = 'infinum/eightshift-libs'; const eightshiftFrontendLibsRepo = 'infinum/eightshift-frontend-libs'; -const eightshiftFrontendLibsRepoUrl = 'https://github.com/infinum/eightshift-frontend-libs'; +const defaultEightshiftFrontendLibsRepoUrl = 'https://github.com/infinum/eightshift-frontend-libs'; /** - * Check if we need to modify dependencies (if user passed an alternative branch for any dependency + * Check if we need to modify dependencies (if user passed an alternative branch or repo for any dependency * as argument) * * @param {object} argv List of CLI arguments. */ const areDependenciesModified = (argv) => { - return argv.eightshiftLibsBranch || argv.eightshiftFrontendLibsBranch; + return argv.eightshiftLibsBranch || argv.eightshiftFrontendLibsBranch || argv.eightshiftLibsRepo || argv.eightshiftFrontendLibsRepoUrl; }; /** @@ -20,18 +20,22 @@ const areDependenciesModified = (argv) => { * * @param {string} projectPath Path to the project. * @param {array} branch Name of the branch to pull from. + * @param {string} repo Custom repository to use if provided. */ -const installModifiedNodeDependencies = async (projectPath, branch) => { +const installModifiedNodeDependencies = async (projectPath, branch, repo) => { + const eightshiftFrontendLibsRepoUrl = repo || defaultEightshiftFrontendLibsRepoUrl; return installNodePackage(projectPath, `${eightshiftFrontendLibsRepoUrl}#${branch} --save`); }; /** - * Installs composer packages and modifies the libs to a specific branch. + * Installs composer packages and modifies the libs to a specific branch or repo. * * @param {string} projectPath Path to the project. * @param {array} branch Name of the branch to pull from. + * @param {string} repo Custom repository to use if provided. */ -const installModifiedComposerDependencies = async (projectPath, branch) => { +const installModifiedComposerDependencies = async (projectPath, branch, repo) => { + const eightshiftLibsRepo = repo || defaultEightshiftLibsRepo; return installComposerPackage(projectPath, `${eightshiftLibsRepo}:dev-${branch}`); };