Compare commits

...

17 commits

Author SHA1 Message Date
Ben Dwyer
e8c4e15b73 Version Bump 2021-10-01 09:56:05 +01:00
Jason Crist
9c31787cbf Merge branch 'trunk' into add/git-sandbox-tools 2021-09-30 14:32:26 -04:00
Jason Crist
cc82bb6027 adjusted script to add new files to SVN if missing 2021-09-30 14:27:42 -04:00
Jason Crist
c70e9f3876 Changed how SVN diff got its message. Added better error control. 2021-09-30 10:09:10 -04:00
Jason Crist
cfd9ef0448 Fixed the svn clean all command to run in the correct folder 2021-09-29 10:29:27 -04:00
Jason Crist
be2544148a Refined 'clean' utilities to include 'clean-all' 2021-09-29 10:23:10 -04:00
Jason Crist
79fc558da5 Adding SVN deploy utilities 2021-09-29 10:12:07 -04:00
Jason Crist
a4055ac57e Clean up and comment scripts 2021-09-29 09:47:31 -04:00
Jason Crist
1d7ac71233 Got a successful push-button deploy 2021-09-29 08:29:10 -04:00
Jason Crist
66897ecfe4 removed duplicate(ish) script 2021-09-29 08:29:10 -04:00
Jason Crist
c9a6e64365 Got push-button-deploy script to a workable state 2021-09-29 08:29:10 -04:00
Jason Crist
8f9c1c7ae8 Add theme utilities javascript style 2021-09-29 08:29:10 -04:00
Jason Crist
89b952ca32 Adding some work-in-progress phabricator tooling 2021-09-29 08:29:10 -04:00
Jason Crist
86efbc0929 added some commends and added 'push' command 2021-09-29 08:29:10 -04:00
Jason Crist
2eff5274a5 added some cloning commands 2021-09-29 08:29:10 -04:00
Jason Crist
64b2f45d24 Pushed missing bash script 2021-09-29 08:29:10 -04:00
Jason Crist
d975e25457 Experiments with git & github tooling 2021-09-29 08:29:10 -04:00
9 changed files with 392 additions and 63 deletions

1
.gitignore vendored
View file

@ -11,6 +11,7 @@ vendor/
.svnignore
.svn
.sandbox-config
.github_token
.wp-env.override.json
#Ignoring headstart files

View file

@ -1,5 +1,6 @@
.git
.github
.github_token
.gitignore
.github_token
.sandbox-config
@ -13,4 +14,5 @@ sandbox.sh
theme-utils.mjs
vendor
node_modules
theme-utils.mjs
**/*.zip

View file

@ -1,6 +1,6 @@
{
"name": "blockbase",
"version": "1.2.3",
"version": "1.2.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,6 +1,6 @@
{
"name": "blockbase",
"version": "1.2.3",
"version": "1.2.4",
"description": "Blank Parent Theme",
"bugs": {
"url": "https://github.com/Automattic/themes/issues"

View file

@ -7,7 +7,7 @@ Description: Blockbase is a simple theme that supports full-site editing. It com
Requires at least: 5.7
Tested up to: 5.7
Requires PHP: 5.7
Version: 1.2.3
Version: 1.2.4
License: GNU General Public License v2 or later
License URI: https://raw.githubusercontent.com/Automattic/themes/trunk/LICENSE
Text Domain: blockbase

186
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "themes",
"version": "1.0.4",
"version": "1.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1883,6 +1883,145 @@
}
}
},
"@octokit/auth-token": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz",
"integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==",
"dev": true,
"requires": {
"@octokit/types": "^6.0.3"
}
},
"@octokit/core": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz",
"integrity": "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==",
"dev": true,
"requires": {
"@octokit/auth-token": "^2.4.4",
"@octokit/graphql": "^4.5.8",
"@octokit/request": "^5.6.0",
"@octokit/request-error": "^2.0.5",
"@octokit/types": "^6.0.3",
"before-after-hook": "^2.2.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/endpoint": {
"version": "6.0.12",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
"dev": true,
"requires": {
"@octokit/types": "^6.0.3",
"is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0"
},
"dependencies": {
"is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"dev": true
}
}
},
"@octokit/graphql": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz",
"integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==",
"dev": true,
"requires": {
"@octokit/request": "^5.6.0",
"@octokit/types": "^6.0.3",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/openapi-types": {
"version": "10.6.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-10.6.0.tgz",
"integrity": "sha512-/iQtZq+zuQJrwawFyjixh333xPu4/KJKk0bFM/Omm4kFlTGw0dWXfq6xCOe5DqONW0faW29Cc9r6p2mvl72aTQ==",
"dev": true
},
"@octokit/plugin-paginate-rest": {
"version": "2.16.5",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.16.5.tgz",
"integrity": "sha512-2PfRGymdBypqRes4Xelu0BAZZRCV/Qg0xgo8UB10UKoghCM+zg640+T5WkRsRD0edwfLBPP3VsJgDyDTG4EIYg==",
"dev": true,
"requires": {
"@octokit/types": "^6.31.0"
}
},
"@octokit/plugin-request-log": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz",
"integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==",
"dev": true
},
"@octokit/plugin-rest-endpoint-methods": {
"version": "5.11.2",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.11.2.tgz",
"integrity": "sha512-oOJ/gC3e6XS5OyvLhS32BslGkKAyt/tgbLJUH1PKfIyDiRm4c6lSm+NHpy/L9WcdiCQji0RPglXTIH+8degjBg==",
"dev": true,
"requires": {
"@octokit/types": "^6.31.0",
"deprecation": "^2.3.1"
}
},
"@octokit/request": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.1.tgz",
"integrity": "sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==",
"dev": true,
"requires": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.1.0",
"@octokit/types": "^6.16.1",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.1",
"universal-user-agent": "^6.0.0"
},
"dependencies": {
"is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"dev": true
}
}
},
"@octokit/request-error": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
"dev": true,
"requires": {
"@octokit/types": "^6.0.3",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
},
"@octokit/rest": {
"version": "18.11.1",
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.11.1.tgz",
"integrity": "sha512-UadwFo10+5TQ/gm/E1r1M3Wkz8WUNyX3TLBO64YmlyZFoCPPLwdhVDHFJ+XGL/+sErPiyps3drvx1I9vMncunA==",
"dev": true,
"requires": {
"@octokit/core": "^3.5.1",
"@octokit/plugin-paginate-rest": "^2.16.0",
"@octokit/plugin-request-log": "^1.0.4",
"@octokit/plugin-rest-endpoint-methods": "5.11.2"
}
},
"@octokit/types": {
"version": "6.31.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.31.0.tgz",
"integrity": "sha512-xobpvYmMYoFSxZB6jL1TPTMMZkxZIBlY145ZKibBJDKCczP1FrLLougtuVOZywGVZdcYs8oq2Bxb3aMjqIFeiw==",
"dev": true,
"requires": {
"@octokit/openapi-types": "^10.5.0"
}
},
"@polka/url": {
"version": "1.0.0-next.12",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.12.tgz",
@ -3554,6 +3693,12 @@
"tweetnacl": "^0.14.3"
}
},
"before-after-hook": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
"integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==",
"dev": true
},
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
@ -5055,6 +5200,12 @@
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==",
"dev": true
},
"define-lazy-prop": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
"dev": true
},
"define-properties": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
@ -5164,6 +5315,12 @@
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
"deprecation": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==",
"dev": true
},
"des.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
@ -7955,8 +8112,7 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz",
"integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==",
"dev": true,
"optional": true
"dev": true
},
"is-extendable": {
"version": "0.1.1",
@ -8156,7 +8312,6 @@
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dev": true,
"optional": true,
"requires": {
"is-docker": "^2.0.0"
}
@ -10840,6 +10995,17 @@
"mimic-fn": "^2.1.0"
}
},
"open": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/open/-/open-8.2.1.tgz",
"integrity": "sha512-rXILpcQlkF/QuFez2BJDf3GsqpjGKbkUUToAIGo9A0Q6ZkoSGogZJulrUdwRkrAsoQvoZsrjCYt8+zblOk7JQQ==",
"dev": true,
"requires": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
"is-wsl": "^2.2.0"
}
},
"opencollective-postinstall": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
@ -13820,7 +13986,8 @@
"dependencies": {
"hosted-git-info": {
"version": "2.8.8",
"resolved": "",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
"dev": true
},
"normalize-package-data": {
@ -14785,6 +14952,12 @@
"unist-util-is": "^3.0.0"
}
},
"universal-user-agent": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==",
"dev": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
@ -15721,7 +15894,8 @@
},
"ssri": {
"version": "6.0.1",
"resolved": "",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
"integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==",
"dev": true,
"requires": {
"figgy-pudding": "^3.5.1"

View file

@ -1,34 +1,39 @@
{
"name": "themes",
"version": "1.0.4",
"version": "1.0.5",
"description": "Automattic public themes",
"author": "automattic",
"license": "GPL-2.0",
"prettier": "@wordpress/prettier-config",
"scripts": {
"sandbox:clean": "./sandbox.sh clean",
"sandbox:pull": "./sandbox.sh pull",
"sandbox:push": "./sandbox.sh push",
"sandbox:push:ignore": "./sandbox.sh push --ignore",
"sandbox:push:force": "./sandbox.sh push --force",
"sandbox:watch": "chokidar '**/*' -i '*/node_modules' -i '.git' -c './sandbox.sh push --ignore' --initial",
"sandbox:clean:git": "node ./theme-utils.mjs clean-sandbox-git",
"sandbox:clean:svn": "node ./theme-utils.mjs clean-sandbox-svn",
"sandbox:clean-all:git": "node ./theme-utils.mjs clean-all-sandbox-git",
"sandbox:clean-all:svn": "node ./theme-utils.mjs clean-all-sandbox-svn",
"local:clean": "git reset --hard HEAD; git clean -fd",
"batch:build:changed": "./theme-batch-utils.sh build",
"batch:build:all": "./theme-batch-utils.sh build-all",
"batch:build:zip:all": "./theme-batch-utils.sh build-org-zip-all",
"batch:build:zip:changed": "./theme-batch-utils.sh build-org-zip-if-changed",
"batch:install": "./theme-batch-utils.sh install-dependencies",
"batch:audit:fix": "./theme-batch-utils.sh audit-dependencies",
"batch:version-bump": "./theme-batch-utils.sh version-bump"
"deploy:version-bump": "node ./theme-utils.mjs version-bump-themes",
"deploy:push:all": "node ./theme-utils.mjs push-to-sandbox",
"deploy:push:changes": "node ./theme-utils.mjs push-changes-to-sandbox",
"deploy:git": "node ./theme-utils.mjs push-button-deploy-git",
"deploy:svn": "node ./theme-utils.mjs push-button-deploy-svn"
},
"devDependencies": {
"@octokit/rest": "^18.11.1",
"@wordpress/prettier-config": "^1.0.1",
"@wordpress/scripts": "^14.0.1",
"@wordpress/stylelint-config": "^19.0.1",
"chokidar-cli": "^2.1.0",
"husky": "^4.3.0",
"lint-staged": "^10.5.4",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"open": "^8.2.1"
},
"husky": {
"hooks": {

125
sandbox-git.sh Executable file
View file

@ -0,0 +1,125 @@
#!/bin/bash
SANDBOX_PUBLIC_THEMES_FOLDER='/home/wpdev/public_html/wp-content/themes/pub';
# Display the status of the repo on sandbox
if [[ $1 == "status" ]]; then
ssh -TA wpcom-sandbox << EOF
cd '$SANDBOX_PUBLIC_THEMES_FOLDER';
git status;
echo
EOF
# Clean the sandbox.
# checkout origin/trunk and ensure it's up-to-date.
# Remove any other changes.
elif [[ $1 == "clean" ]]; then
ssh -TA wpcom-sandbox << EOF
cd '$SANDBOX_PUBLIC_THEMES_FOLDER';
git reset --hard HEAD;
git clean -fd;
git checkout trunk;
git pull;
echo
EOF
# Add the public github as a remote to your sandbox
# This is useful to checkout branches from github directly to your sandbox
elif [[ $1 == "add-github-remote" ]]; then
ssh -TA wpcom-sandbox << EOF
cd '$SANDBOX_PUBLIC_THEMES_FOLDER';
git remote add github git@github.com:Automattic/themes.git
git fetch github
echo
EOF
# Add the sandbox as a remote to your local
# This doesn't seem to actually work right now...
# This allows you to refer to the github as "origin" and your sandbox as "sandbox"
# Note that for this to work your ~/.ssh/config must have
# Host wpcom-sandbox
# User wpdev
# HostName SANDBOXURL.wordpress.com
# ForwardAgent yes
elif [[ $1 == "add-sandbox-remote" ]]; then
git remote add sandbox wpdev@wpcom-sandbox:/home/wpdev/public_html/wp-content/themes/pub/.git
# Switch the sandbox to a given github branch.
# Defaults to current branch if not provided.
elif [[ $1 == "checkout-branch" ]]; then
if [[ -z $2 ]]; then
BRANCH_NAME=$(git symbolic-ref --short HEAD)
else
BRANCH_NAME=$2;
fi
ssh -TA wpcom-sandbox << EOF
cd '$SANDBOX_PUBLIC_THEMES_FOLDER'
git fetch
git checkout github/$BRANCH_NAME
echo
EOF
# First ensure that the local and sandbox are on the same branch.
# Then push whatever has changed in the local branch to the sandbox via rsync.
# This isn't going to work because the public repo (github) and private repo (a8c)
# don't have common ancestry
elif [[ $1 == "push-local-diff" ]]; then
ssh -TA wpcom-sandbox << EOF
echo '#TODO: Everything';
EOF
elif [[ $1 == "push" ]]; then
rsync -av --no-p --no-times --exclude-from='.sandbox-ignore' ./ wpcom-sandbox:$SANDBOX_PUBLIC_THEMES_FOLDER/
elif [[ $1 == "create-diff" ]]; then
#TODO: Do some fancy git stuff to build the commit message
commit_message="Deploy Themes [THEME UMBRELLA PROJECT VERSION] to wpcom
Summary:
This is a test. Please ignore this diff
This should reflect all of the Pull Requests between THIS BRANCH and TRUNK (stating at the point of diversion)
Test Plan: Execute Smoke Test
Reviewers:
Subscribers:
"
ssh -TA wpcom-sandbox << EOF
cd $SANDBOX_PUBLIC_THEMES_FOLDER
git branch -D deploy
git checkout -b deploy
git add --all
git commit -m "$commit_message"
arc diff --create --verbatim
EOF
#TODO: Pull the Phabricator URL from the output above
# Open phabricator URL in my browser
# Add Phabricator URL to the PR I'm working with (as a comment) ???
elif [[ $1 == "checkout-diff" ]]; then
diff_id=$2
ssh -TA wpcom-sandbox << EOF
cd $SANDBOX_PUBLIC_THEMES_FOLDER
arc patch $diff_id
EOF
elif [[ $1 == "deploy-diff" ]]; then
ssh -TA wpcom-sandbox << EOF
cd $SANDBOX_PUBLIC_THEMES_FOLDER
arc land --onto trunk --preview
EOF
# Clone the sandbox here.
# I don't think you would ever actually do this one... if you have this script then you've already cloned the repo from SOMEWHERE.
# It's mostly here as a reference.
elif [[ $1 == "clone" ]]; then
git clone wpdev@wpcom-sandbox:/home/wpdev/public_html/wp-content/themes/pub/.git .
# All Done
fi

View file

@ -48,24 +48,35 @@ async function pushButtonDeployGit() {
//TODO: If this branch isn't current with origin exit and require a pull
//TODO: If the sandbox isn't in 'git' mode exit
let hash = await getLastDeployedHash();
try {
await versionBumpThemes({
commit: true
});
//TODO: Can these be automagically uploaded?
//await buildChangedOrgZips();
let hash = await getLastDeployedHash();
await cleanSandboxGit();
await pushChangesToSandbox();
await updateLastDeployedHash();
let diffUrl = await createGitPhabricatorDiff(hash);
await versionBumpThemes({
commit: true
});
await tagDeployment({
hash: hash,
diffUrl: diffUrl
});
//TODO: Can these be automagically uploaded?
//await buildChangedOrgZips();
await cleanSandboxGit();
await pushChangesToSandbox();
await updateLastDeployedHash();
let diffUrl = await createGitPhabricatorDiff(hash);
//push changes (from version bump)
await executeCommand('git push');
await tagDeployment({
hash: hash,
diffUrl: diffUrl
});
}
catch (err) {
console.log("ERROR with deply script: ", err);
}
}
/*
@ -87,24 +98,34 @@ async function pushButtonDeploySvn(){
//TODO: If this branch isn't current with origin exit and require a pull
//TODO: If the sandbox isn't in 'svn' mode exit
let hash = await getLastDeployedHash();
try {
await versionBumpThemes({
commit: true
});
let hash = await getLastDeployedHash();
//TODO: Can these be automagically uploaded?
//await buildChangedOrgZips();
await versionBumpThemes({
commit: true
});
await cleanSandboxSvn();
await pushChangesToSandbox();
await updateLastDeployedHash();
let diffUrl = await createSvnPhabricatorDiff(hash);
//TODO: Can these be automagically uploaded?
//await buildChangedOrgZips();
await tagDeployment({
hash: hash,
diffUrl: diffUrl
});
await cleanSandboxSvn();
await pushChangesToSandbox();
await updateLastDeployedHash();
let diffUrl = await createSvnPhabricatorDiff(hash);
//push changes (from version bump)
await executeCommand('git push');
await tagDeployment({
hash: hash,
diffUrl: diffUrl
});
}
catch (err) {
console.log("ERROR with deply script: ", err);
}
}
/*
@ -130,7 +151,7 @@ async function updateLastDeployedHash() {
/*
Version bump (increment version patch) any theme project that has had changes since the last deployment.
If a theme's version has already been changed since that last deployment then do not version bump it.
If a theme's version has already been changed since that last deployment then do not version bump it.
If any theme projects have had a version bump also version bump the parent project.
Optionally commit and push the version bump to git.
*/
@ -169,7 +190,6 @@ async function versionBumpThemes(options) {
console.log('commiting version-bump');
let commitResult = await executeCommand(`
git commit -a -m "Version Bump";
git push
`);
console.log(commitResult);
}
@ -206,13 +226,13 @@ async function checkThemeForVersionBump(theme, hash){
`);
let previousPackage = JSON.parse(previousPackageString);
let currentPackage = JSON.parse(fs.readFileSync(`${theme}/package.json`))
return previousPackage.version != currentPackage.version;
return previousPackage.version != currentPackage.version;
}
/*
Determine if a theme has had changes since a given hash.
Used by versionBumpThemes
*/
*/
async function checkThemeForChanges(theme, hash){
let uncomittedChanges = await executeCommand(`git diff-index --name-only HEAD -- ${theme}`);
let comittedChanges = await executeCommand(`git diff --name-only ${hash} HEAD -- ${theme}`);
@ -365,7 +385,7 @@ async function pushChangesToSandbox() {
async function getComittedChangesSinceHash(hash) {
let comittedChanges = await executeCommand(`git diff ${hash} HEAD --name-only`);
comittedChanges = comittedChanges.replace(/\r?\n|\r/g, " ").split(" ");
comittedChanges = comittedChanges.replace(/\r?\n|\r/g, " ").split(" ");
let uncomittedChanges = await executeCommand(`git diff HEAD --name-only`);
uncomittedChanges = uncomittedChanges.replace(/\r?\n|\r/g, " ").split(" ");
@ -382,12 +402,12 @@ async function getDeletedFilesSince(hash){
let deletedSinceHash = await executeCommand(`
git log --format=format:"" --name-only -M100% --diff-filter=D ${hash}..HEAD
`);
deletedSinceHash = deletedSinceHash.replace(/\r?\n|\r/g, " ").trim().split(" ");
deletedSinceHash = deletedSinceHash.replace(/\r?\n|\r/g, " ").trim().split(" ");
let deletedAndUncomitted = await executeCommand(`
git diff HEAD --name-only --diff-filter=D
`);
deletedAndUncomitted = deletedAndUncomitted.replace(/\r?\n|\r/g, " ").trim().split(" ");
deletedAndUncomitted = deletedAndUncomitted.replace(/\r?\n|\r/g, " ").trim().split(" ");
return deletedSinceHash.concat(deletedAndUncomitted).filter( item => {
return item != '';
@ -404,14 +424,14 @@ async function buildPhabricatorCommitMessageSince(hash){
let projectVersion = await executeCommand(`node -p "require('./package.json').version"`);
let logs = await executeCommand(`git log --reverse --pretty=format:%s ${hash}..HEAD`);
return `Deploy Themes ${projectVersion} to wpcom
Summary:
${logs}
Test Plan: Execute Smoke Test
Reviewers:
Subscribers:
`;
}
@ -455,14 +475,17 @@ async function createGitPhabricatorDiff(hash) {
async function createSvnPhabricatorDiff(hash) {
console.log('creating Phabricator Diff');
let commitMessage = await buildPhabricatorCommitMessageSince(hash);
const commitTempFileLocation = '/tmp/theme-deploy-comment.txt';
const commitMessage = await buildPhabricatorCommitMessageSince(hash);
let result = await executeOnSandbox(`
const result = await executeOnSandbox(`
cd ${sandboxPublicThemesFolder};
arc diff --create --message ${commitMessage}
echo '${commitMessage}' > ${commitTempFileLocation}
svn add --force * --auto-props --parents --depth infinity -q
arc diff --create --message-file ${commitTempFileLocation}
`);
let phabricatorUrl = getPhabricatorUrlFromResponse(result);
const phabricatorUrl = getPhabricatorUrlFromResponse(result);
console.log('Diff Created at: ', phabricatorUrl);
@ -478,7 +501,7 @@ async function createSvnPhabricatorDiff(hash) {
Used by createGitPhabricatorDiff
*/
function getPhabricatorUrlFromResponse(response){
return response
return response
?.split('\n')
?.find( item => {
return item.includes('Revision URI: ');
@ -486,7 +509,6 @@ function getPhabricatorUrlFromResponse(response){
?.split("Revision URI: ")[1];
}
/*
Create a git tag at the current hash.
In the description include the commit logs since the given hash.
@ -521,8 +543,8 @@ Host wpcom-sandbox
ForwardAgent yes
*/
function executeOnSandbox(command){
return executeCommand(`ssh -TA ${remoteSSH} << EOF
${command}
return executeCommand(`ssh -TA ${remoteSSH} << EOF
${command}
EOF`);
}