Skip to content

Clone a branch to see preview deploy #952

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default class Application extends JSONAPIAdapter {
let projectName = this.currentProject;

if (['namespace', 'class', 'module'].indexOf(modelName) > -1) {
let [version] = id.replace(`${projectName}-`, '').split('-');
const match = id.match(/\d+\.\d+\.\d+(?:-[\w.]+)?/);
const version = match ? match[0] : null;
let revId = this.metaStore.getRevId(projectName, version, modelName, id);

let modelNameToUse = modelName;
Expand Down
3 changes: 3 additions & 0 deletions app/utils/get-compact-version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export default function getCompactVersion(fullVersion) {
if (fullVersion.includes('-')) {
return fullVersion;
}
return fullVersion.split('.').slice(0, 2).join('.');
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "tests"
},
"scripts": {
"clone": "rm -rf ember-api-docs-data && git clone --depth=1 https://github.com/ember-learn/ember-api-docs-data.git",
"clone": "rm -rf ember-api-docs-data && git clone --depth=1 -b update-api-docs-6.8.0-alpha.1 https://github.com/ember-learn/ember-api-docs-data.git",
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
Expand Down
46 changes: 37 additions & 9 deletions prember-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ module.exports = function () {

const fullProjectVersions = readdirSync(
`ember-api-docs-data/json-docs/${p}`
).filter((v) => v.match(/\d+\.\d+\.\d+/));
).filter((v) => !!semver.valid(v));

// add landing page for each of the projects versions
const projectVersions = fullProjectVersions.map((v) => {
let [, major, minor] = v.match(/(\d+)\.(\d+)\.\d+/);
return `${major}.${minor}`;
}); // uniq
const projectVersions = fullProjectVersions
.map((v) => {
let parsed = semver.parse(v);
if (!parsed) return null;
if (parsed.prerelease && parsed.prerelease.length > 0) {
return `${parsed.major}.${parsed.minor}.${
parsed.patch
}-${parsed.prerelease.join('.')}`;
}
return `${parsed.major}.${parsed.minor}`;
})
.filter(Boolean);

const uniqueProjectVersions = [...new Set(projectVersions)];

Expand All @@ -45,9 +53,18 @@ module.exports = function () {
const oldVersions = ['1.13', '2.18', '3.28', '4.4', '4.8', '4.12'];

uniqueProjectVersions.forEach((uniqVersion) => {
let isPreRelease = uniqVersion.includes('-');
let baseVersion = isPreRelease ? uniqVersion.split('-')[0] : uniqVersion;

if (
!oldVersions.includes(baseVersion) &&
!semver.valid(`${baseVersion}.0`)
) {
return;
}
if (
!oldVersions.includes(uniqVersion) &&
!semver.gte(`${uniqVersion}.0`, '5.0.0')
!oldVersions.includes(baseVersion) &&
!semver.gte(`${baseVersion}.0`, '5.0.0')
) {
return;
}
Expand All @@ -56,14 +73,25 @@ module.exports = function () {

const sortedPatchVersions = fullProjectVersions
.filter((projectVersion) => {
// console.log("comparing", projectVersion, uniqVersion, semver.satisfies(projectVersion, uniqVersion))
return semver.satisfies(projectVersion, uniqVersion);
let parsed = semver.parse(projectVersion);
if (!parsed) return false;
if (isPreRelease) {
return (
`${parsed.major}.${parsed.minor}.${
parsed.patch
}-${parsed.prerelease.join('.')}` === uniqVersion
);
} else {
return `${parsed.major}.${parsed.minor}` === uniqVersion;
}
})
.sort(cmp);

const highestPatchVersion =
sortedPatchVersions[sortedPatchVersions.length - 1];

if (!highestPatchVersion) return;

const revIndex = require(`${__dirname}/ember-api-docs-data/rev-index/${p}-${highestPatchVersion}.json`);

['classes', 'namespaces', 'modules'].forEach((entity) => {
Expand Down
Loading