Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Apr 11, 2024
1 parent a02d6f9 commit 7f6dd6b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 22 deletions.
10 changes: 7 additions & 3 deletions packages/toolkit/PROJECTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A standard 10up GitLab project initialized with 10up Toolkit looks like the foll
```
.tenup-ci.yml
.gitlab-ci.yml
/deploy-scripts
/scripts
build.sh
```

Expand All @@ -28,11 +28,15 @@ variables:
project_name: "10up Project"
main_branch: "trunk"
php_version: "8.2"
build_script_path: "./deploy-scripts/build.sh"
remote_deploy_location: "[email protected]:/var/www/my-project"
wordpress_version: "6.4"
deploy_map_from: "./"
deploy_map_to: "wp-content"

deploy_script_path: ""
build_script_path: ""
create_payload_script_path: ""
deploy_file_excludes: ""
```
## Commands
Expand All @@ -51,7 +55,7 @@ List of commands:
10up-toolkit project build
```

`build` simply executes your `deploy-scripts/build.sh` file. `build` will be executed before deploying files.
`build` simply executes your `scripts/build.sh` file (or other path you specify). `build` will be executed before deploying files.

```bash
10up-toolkit project create-payload
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/project/default-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"project_name": "10up Project",
"main_branch": "trunk",
"php_version": "8.2",
"build_script_path": "./deploy-scripts/build.sh",
"build_script_path": "",
"wordpress_version": "",
"deploy_script_path": "",
"remote_deploy_location": "",
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/project/deploy-file-excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ installed.json
/tasks
/conf
/deploy-scripts
/scripts
.gitlab-ci.yml
*/package-lock.json
package-lock.json
Expand Down
1 change: 0 additions & 1 deletion packages/toolkit/project/local/.tenup-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ variables:
project_name: "{project_name}"
main_branch: "{main_branch}"
php_version: "{php_version}"
build_script_path: "{build_script_path}"
wordpress_version: "{wordpress_version}"
remote_deploy_location: "{remote_deploy_location}"
deploy_map_from: "{deploy_map_from}"
Expand Down
5 changes: 2 additions & 3 deletions packages/toolkit/scripts/project/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ const main = async () => {

setEnvVariables(variables);

// Execute the build file at projectroot/deploy-scripts/build.sh
if (fs.existsSync(`${root}/deploy-scripts/build.sh`)) {
execSync(`. ${__dirname}/bash/build-setup.sh; . ${root}/deploy-scripts/build.sh`, {
if (fs.existsSync(variables.build_script_path)) {
execSync(`. ${__dirname}/bash/build-setup.sh; . ${variables.build_script_path}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
stdio: 'inherit',
});
} else {
Expand Down
20 changes: 10 additions & 10 deletions packages/toolkit/scripts/project/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ const main = async () => {
setEnvVariables(variables);

// If we specify a deploy script, use it
if (variables.deploy_script && fs.existsSync(`${root}/${variables.deploy_script}`)) {
execSync(`sh ${root}/${variables.deploy_script}`, { stdio: 'inherit' });
}

// Execute the script at deploy-$method.sh
const deployScript = `${__dirname}/bash/deploy-${method}.sh`;
if (fs.existsSync(deployScript)) {
execSync(`sh ${deployScript}`, { stdio: 'inherit' });
if (variables.deploy_script_path && fs.existsSync(`${root}/${variables.deploy_script_path}`)) {
execSync(`sh ${root}/${variables.deploy_script_path}`, { stdio: 'inherit' });
} else {
log(`No deploy-${method}.sh script found.`);
process.exit(1);
// Execute the script at deploy-$method.sh
const deployScript = `${__dirname}/bash/deploy-${method}.sh`;
if (fs.existsSync(deployScript)) {
execSync(`sh ${deployScript}`, { stdio: 'inherit' });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
} else {
log(`No deploy-${method}.sh script found.`);
process.exit(1);
}
}

log(chalk.green('Deploy complete.'));
Expand Down
22 changes: 18 additions & 4 deletions packages/toolkit/utils/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,30 @@ const getProjectVariables = () => {
data.variables.project_root = projectRoot;

if (data.variables.create_payload_script_path) {
data.variables.create_payload_script_path = `${projectRoot}/${data.variables.create_payload_script_path}`;
data.variables.create_payload_script_path = resolve(
`${projectRoot}/${data.variables.create_payload_script_path}`,
);
} else {
data.variables.create_payload_script_path = `${__dirname}/../scripts/project/bash/create-payload.sh`;
data.variables.create_payload_script_path = resolve(
`${__dirname}/../scripts/project/bash/create-payload.sh`,
);
}

if (data.variables.build_script_path) {
data.variables.build_script_path = resolve(
`${projectRoot}/${data.variables.build_script_path}`,
);
} else {
data.variables.build_script_path = `${projectRoot}/scripts/build.sh`;
}

if (!data.variables.deploy_file_excludes) {
data.variables.deploy_file_excludes = `${__dirname}/../project/deploy-file-excludes.txt`;
data.variables.deploy_file_excludes = resolve(
`${__dirname}/../project/deploy-file-excludes.txt`,
);
}

data.variables.toolkit_path = fs.realpathSync(`${__dirname}/../`);
data.variables.toolkit_path = resolve(`${__dirname}/../`);

return data.variables;
};
Expand Down

0 comments on commit 7f6dd6b

Please sign in to comment.