Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init fix #402

Merged
merged 9 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-birds-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Fix init command
1 change: 0 additions & 1 deletion packages/toolkit/PROJECTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ The following are additional optional variables that allow you to use custom scr
deploy_script_path: "" # Custom deploy script
build_script_path: "" # For using a build script in a different location
create_payload_script_path: "" # Custom create payload script
deploy_file_excludes: "" # Custom deploy file exclusions
```

## Commands
Expand Down
1 change: 0 additions & 1 deletion packages/toolkit/project/default-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"build_script_path": "",
"wordpress_version": "",
"deploy_script_path": "",
"deploy_file_excludes": "",
"create_payload_script_path": "",
"environments": []
}
18 changes: 2 additions & 16 deletions packages/toolkit/project/gitlab/.gitlab-ci.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ include:
ref: trunk
file: /main.yml

setup_10up_toolkit:
stage: .pre
script: |
if [ ! -d "toolkit" ] ; then
git clone --verbose -b project-command https://github.com/10up/10up-toolkit.git toolkit
fi
rm -rf 10up-toolkit
ln -s toolkit/packages/toolkit/bin/10up-toolkit.js 10up-toolkit
cd toolkit
npm install
artifacts:
paths:
- toolkit
- 10up-toolkit

test_syntax:
stage: test
script:
Expand All @@ -39,7 +24,8 @@ test_virusscan:
build_plugins_and_themes:
stage: build
script:
- ./10up-toolkit project create-payload $CI_COMMIT_REF_NAME
- nvm install 18
- npx 10up-toolkit@next project create-payload $CI_COMMIT_REF_NAME
artifacts:
paths:
- payload
Expand Down
2 changes: 2 additions & 0 deletions packages/toolkit/scripts/project/bash/build-setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

maybe_init_nvm() {

if [ $(find . -name .nvmrc | wc -l) -gt 0 ] && [ ! -f $NVM_DIR/nvm.sh ]; then
Expand Down
6 changes: 3 additions & 3 deletions packages/toolkit/scripts/project/bash/create-payload.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
Expand All @@ -15,6 +17,4 @@ download https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz wordpress.t
tar --strip-components=1 -zxmf wordpress.tar.gz -C .
rm wordpress.tar.gz

echo "rsync -avz --exclude-from=$deploy_file_excludes $project_root/$deploy_from $deploy_to_subdir"

rsync -avz --exclude-from=$deploy_file_excludes $project_root/$deploy_from $deploy_to_subdir
rsync -avz --exclude-from=$deploy_file_excludes_absolute $project_root/$deploy_from $deploy_to_subdir
4 changes: 3 additions & 1 deletion packages/toolkit/scripts/project/bash/init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# Create dir if it does not exist
if [ ! -d "$init_path" ]; then
mkdir -p "$init_path"
Expand All @@ -20,7 +22,7 @@ fi
LANG=C

if [ "$(uname)" = "Darwin" ]; then
sediopt=( -i '')
sediopt=( -i '' )
else
sediopt=( -i )
fi
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/scripts/project/create-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const run = async () => {
await require('./build').run();

if (fs.existsSync(variables.create_payload_script_path)) {
execSync(`sh ${variables.create_payload_script_path}`, { stdio: 'inherit' });
execSync(`bash ${variables.create_payload_script_path}`, { stdio: 'inherit' });
}

log(chalk.green('Payload created.'));
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/scripts/project/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

const initScript = `${__dirname}/bash/init.sh`;

execSync(`sh ${initScript}`, { stdio: 'inherit' });
execSync(`bash ${initScript}`, { stdio: 'inherit' });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

// Load the contents of the .tenup.yml file into a string
let configFile = fs.readFileSync(`${path}/.tenup.yml`, 'utf8');
Expand Down
5 changes: 2 additions & 3 deletions packages/toolkit/utils/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
/**
* Setuip environment variables
*
* @param {*} variables

Check warning on line 65 in packages/toolkit/utils/project.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20)

Missing JSDoc @param "variables" description
*/
const setEnvVariables = (variables) => {
// Loop through variables and set them as environment variables
Expand All @@ -79,7 +79,7 @@
*
* @param {*} branch Branch name
* @param {*} environments All environments
* @returns {}

Check warning on line 82 in packages/toolkit/utils/project.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20)

Missing JSDoc @returns type
*/
const getEnvironmentFromBranch = (branch, environments = []) => {
let matchedEnvironment = null;
Expand Down Expand Up @@ -136,9 +136,8 @@
data.build_script_path = `${projectRoot}/scripts/build.sh`;
}

if (!data.deploy_file_excludes) {
data.deploy_file_excludes = `./toolkit/packages/toolkit/project/deploy-file-excludes.txt`;
}
data.deploy_file_excludes = `./scripts/deploy-excludes.txt`;
data.deploy_file_excludes_absolute = `${projectRoot}/scripts/deploy-excludes.txt`;

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

Expand Down
Loading