Skip to content

Commit

Permalink
Gather doc versions from git tags
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Apr 13, 2018
1 parent f18813b commit 5e3ff4d
Show file tree
Hide file tree
Showing 51 changed files with 99 additions and 4,182 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ matrix:

# Website
- language: node_js
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-4.9-dev
env:
- NAME='Website - master'
node_js: 8
Expand Down
5 changes: 5 additions & 0 deletions docs/Guide.DebuggingInXcode.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
id: Guide.DebuggingInXcode
title: Debugging in Xcode During Detox Tests
---

# Debugging in Xcode During Detox Tests

> This is mostly useful for investigating weird crashes or when contributing to Detox itself. **This workflow isn't standard. Don't use it unless you have a good reason.**
Expand Down
1 change: 1 addition & 0 deletions scripts/publish-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ else
echo "machine github.com login $GIT_USER password $GIT_TOKEN" > ~/.netrc;
cd website;
npm install;
npm run gatherDocs
GIT_USER=$GIT_USER CURRENT_BRANCH=master npm run publish-gh-pages;
fi
7 changes: 7 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ website/node_modules

website/i18n/*
!website/i18n/en.json

versioned_docs/*
!versioned_docs/.gitkeep

versioned_sidebars/*
!versioned_sidebars/.gitkeep
versions.json
73 changes: 73 additions & 0 deletions website/gatherDocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node
const fs = require("fs-extra");
const git = require("nodegit");
const execSync = require('child_process').execSync;
const REPO_URL = "https://github.com/wix/detox.git"

// From https://gist.github.com/joerx/3296d972735adc5b4ec1
function clearRequireCache() {
Object.keys(require.cache).forEach(function (key) {
delete require.cache[key];
});
}

function getMajorVersion(tag) {
return parseInt(tag.split('.')[0], 10)
}

async function getVersions() {
const tmp = fs.mkdtempSync('detox-versions');
const repo = await git.Clone(REPO_URL, tmp);
const tags = await git.Tag.list(repo);

const semverTags = tags
.filter(tag => tag.split('.').length === 3 && getMajorVersion(tag) >= 6)
.sort()
.reverse();
await fs.remove(tmp);
return semverTags;
}

const sidebars = [];

(async function () {
const versions = await getVersions();
console.log("Cleanup versioned docs");
await fs.remove("./versions.json")
await fs.emptyDir("./versioned_docs");
await fs.emptyDir("./versioned_sidebars");

fs.writeFileSync("./versions.json", JSON.stringify(versions), "utf8");
for (let version of versions) {
const tempDir = fs.mkdtempSync(`detox-${version}`);
console.log("Clone repository into tmp directory");
const repo = await git.Clone(REPO_URL, tempDir);

console.log("Checking out version", version);
await repo.checkoutBranch(version);

// We need to do this as we forgot the header in this one file, but added git tags with it included
console.log("Temporary fix for Guide.DebuggingInXcode")
const header = '---\nid: Guide.DebuggingInXcode\ntitle: Debugging in Xcode During Detox Tests\n---';
execSync(
`echo "${header}" | cat - Guide.DebuggingInXcode.md > /tmp/out && mv /tmp/out Guide.DebuggingInXcode.md`,
{
cwd: tempDir + "/docs"
}
);

console.log("Generating versioned doc for", version)
execSync(`npm install && rm versions.json && rm -rf {versioned_docs,versioned_sidebars} && npm run version ${version}`, { cwd: tempDir + '/website' })

console.log("Copy versioned doc");
fs.copySync(`${tempDir}/website/versioned_docs/version-${version}`, `./versioned_docs/version-${version}`);

console.log("Copy sidebar into versioned_sidebars");
fs.copyFileSync(`${tempDir}/website/versioned_sidebars/version-${version}-sidebars.json`, `./versioned_sidebars/version-${version}-sidebars.json`)

console.log("Cleanup temporary clone");
await fs.remove(tempDir);
console.log(`Done with ${version}\n\n`);
}
})();

2 changes: 1 addition & 1 deletion website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"APIRef.TestLifecycle": "Test Lifecycle",
"APIRef.waitFor": "Manual Synchronization Using `waitFor`",
"Guide.Contributing": "Contributing",
"Guide.DebuggingInXcode": "Guide.DebuggingInXcode",
"Guide.DebuggingInXcode": "Debugging in Xcode During Detox Tests",
"Guide.DevelopingWhileWritingTests": "Developing Your App While Writing Tests",
"Guide.Jest": "Jest",
"Guide.Migration": "Migration Guide",
Expand Down
7 changes: 6 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "docusaurus-version",
"rename-version": "docusaurus-rename-version"
"rename-version": "docusaurus-rename-version",
"gatherDocs": "node ./gatherDocs"
},
"devDependencies": {
"docusaurus": "^1.0.4"
},
"dependencies": {
"fs-extra": "^5.0.0",
"nodegit": "^0.21.0"
}
}
110 changes: 0 additions & 110 deletions website/versioned_docs/version-6.X/APIRef.ActionsOnElement.md

This file was deleted.

84 changes: 0 additions & 84 deletions website/versioned_docs/version-6.X/APIRef.Artifacts.md

This file was deleted.

Loading

0 comments on commit 5e3ff4d

Please sign in to comment.