Skip to content

Commit

Permalink
Init fix (#402)
Browse files Browse the repository at this point in the history
Co-authored-by: Taylor Lovett <tlovett88@gmail.com>
  • Loading branch information
nicholasio and tlovett1 authored May 29, 2024
1 parent 84c7224 commit 58d5861
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 27 deletions.
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 run = async () => {

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

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

// 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 @@ -136,9 +136,8 @@ const getProjectVariables = (path = '.') => {
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

0 comments on commit 58d5861

Please sign in to comment.