Skip to content

Commit

Permalink
Pnpm 8 (#848)
Browse files Browse the repository at this point in the history
* Update to pnpm8

* Update workflows

* Fix engines / volta specification

* Re-roll lockfile

* Bump ember-async-data

* Upgrade QUnit + related types

* Ember concurrency is not compatible with the preview types so the test-app can't use them

* Success?

* '@ember/owner' isn't available yet

* Remove ember-export-application-global

* Get typedoc working and try to fix util output

* Fixup the docs a bit

* Give up on @ember/owner for now -- will fix in separate PR
  • Loading branch information
NullVoxPopuli authored Apr 4, 2023
1 parent 3bea077 commit 370976b
Show file tree
Hide file tree
Showing 16 changed files with 4,645 additions and 5,040 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2

lint:
name: Lint
runs-on: ubuntu-latest
needs: [install_dependencies]
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- name: Lint
run: pnpm lint

Expand All @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/assert-build


Expand All @@ -61,7 +61,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- name: 'Change TS to ${{ matrix.typescript-scenario }}'
run: 'pnpm add --save-dev ${{ matrix.typescript-scenario}}'
Expand All @@ -84,7 +84,7 @@ jobs:
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- run: pnpm --filter test-app test:ember

Expand All @@ -95,7 +95,7 @@ jobs:
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
with:
no-lockfile: true
- uses: ./.github/actions/download-built-package
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- name: Run Tests
working-directory: ./test-app
Expand All @@ -150,7 +150,7 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- name: Create Release Pull Request or Publish to npm
id: changesets
Expand All @@ -173,7 +173,7 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- name: measure asset sizes
run: node ./dev/estimate-bytes/index.js
Expand All @@ -198,7 +198,7 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- run: |
pnpm build:docs
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: NullVoxPopuli/action-setup-pnpm@v1.1.0
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: ./.github/actions/download-built-package
- uses: marocchino/sticky-pull-request-comment@v2
with:
Expand Down
109 changes: 109 additions & 0 deletions docs/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';

import { execa } from 'execa';
import fse from 'fs-extra';


const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

const packagePath = path.resolve(__dirname, '../ember-resources/package.json');

async function main() {

let pkg = await fse.readJson(packagePath);
let config = await fse.readJson(path.resolve(__dirname, './typedoc.config.json'));

let packageExports = pkg.exports;

let relevant = Object.keys(packageExports).filter((importPath) => {
if (importPath === '.') return;
if (importPath.startsWith('./core')) return;
if (importPath === './util') return;
if (importPath === './addon-main.js') return;
if (importPath.includes('cell')) return;

return true;
});

let expectedOutputPath = {};

// Clear links
config.sidebarLinks = {};

// Update links
for (let importPath of relevant) {
let normalized = importPath.replace('./util/', '').replace('./', '').replaceAll(/-/g, ' ');
let split = normalized.split(' ');
let camelCase = split.map((word, i) => i === 0 ? word : word[0].toUpperCase() + word.slice(1)).join('');
let outputPath = `/utils/${camelCase}`;

expectedOutputPath[importPath] = outputPath;

let link = `${outputPath}/index.html`;


config.sidebarLinks[camelCase] = link;
}

// manual overrides because reasons
// Default is an index.html for all exports, which may not be ideal
config.sidebarLinks['link'] = '/utils/link/functions/link.html';
config.sidebarLinks['service'] = '/utils/service/functions/service.html';
config.sidebarLinks['map'] = '/utils/map/functions/map.html';
config.sidebarLinks['helper'] = '/utils/helper/functions/helper.html';
delete config.sidebarLinks['function'];
config.sidebarLinks['trackedFunction'] = '/utils/function/functions/trackedFunction.html';
config.sidebarLinks['emberConcurrency'] = '/utils/emberConcurrency/functions/trackedTask.html';
config.sidebarLinks['debounce'] = '/utils/debounce/functions/debounce.html';
config.sidebarLinks['keepLatest'] = '/utils/keepLatest/functions/keepLatest.html';
config.sidebarLinks['remoteData'] = '/utils/remoteData/functions/RemoteData.html';

await fse.writeJson(path.resolve(__dirname, './typedoc.config.json'), config, { spaces: 2 });

await buildDefault();

// Generate type-doc outputs with
for (let [importPath, outputPath] of Object.entries(expectedOutputPath)) {
let configCopy = { ...config };

configCopy.entryPoints = [
path.resolve('../ember-resources/src', importPath + '.ts'),
];
configCopy.tsconfig = path.resolve(path.join(__dirname, '../ember-resources/tsconfig.json'));
configCopy.navigationLinks = {};
configCopy.navigationLinks['Back to ember-resources'] = '/index.html';
configCopy.navigationLinks['GitHub'] = 'https://github.com/NullVoxPopuli/ember-resources';
configCopy.sidebarLinks = {};
configCopy.sidebarLinks['Back to ember-resources'] = '/index.html';
configCopy.readme = 'none';
configCopy.customCss = path.resolve(path.join(__dirname, './custom.css'));
delete configCopy.json;
configCopy.out = path.join(__dirname, `dist/${outputPath}`);
configCopy.cleanOutputDir = false;

let configLocation = `/tmp/ember-resources-docs/${outputPath}/`;

await fse.ensureDir(configLocation);
await fse.writeJson(path.join(configLocation, 'typedoc.config.json'), configCopy, { spaces: 2 });

await build(configLocation);
}
}

main();

async function buildDefault() {
await execa('pnpm', ['typedoc', '--options', './typedoc.config.json'], {
cwd: __dirname,
stdio: 'inherit',
});
}

async function build(configLocation) {
await execa('pnpm', ['typedoc', '--options', path.join(configLocation, './typedoc.config.json')], {
cwd: __dirname,
stdio: 'inherit',
});
}
39 changes: 39 additions & 0 deletions docs/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.col-menu.menu-sticky-wrap {
display: flex;
flex-direction: column-reverse;
justify-content: start;
}

.tsd-navigation.settings {
display: none;
}

.tsd-navigation.primary {
display: none;
}

#tsd-sidebar-links::before {
content: 'Utils';
font-weight: bold;
margin-bottom: 0.4rem;
display: block;
margin-top: 0.5rem;
margin-left: -0.25rem;
}

#tsd-sidebar-links a::after,
#tsd-toolbar-links a::after {
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"/></svg>');
width: 0.75rem;
height: 0.75rem;
display: inline-block;
margin-left: 0.5rem;
color: currentColor;
}

@media (prefers-color-scheme: dark) {
#tsd-sidebar-links a::after,
#tsd-toolbar-links a::after {
filter: invert(1);
}
}
14 changes: 11 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
"private": true,
"scripts": {
"start": "pnpm docs:watch",
"docs:collect": "typedoc --options ./typedoc.config.json",
"debug": "npx html-pages ./dist --no-cache",
"docs:collect": "node ./build.mjs",
"docs:watch": "typedoc --options ./typedoc.config.json --watch"
},
"devDependencies": {
"typedoc": "^0.23.14",
"typedoc": "^0.23.28",
"typedoc-github-wiki-theme": "^1.0.1",
"typedoc-gitlab-wiki-theme": "^1.0.0",
"typedoc-plugin-markdown": "^3.14.0",
"typedoc-plugin-markdown-pages": "^0.3.0",
"typedoc-plugin-mdn-links": "^3.0.0",
"typedoc-plugin-mdn-links": "^3.0.3",
"typescript": "^5.0.0"
},
"dependencies": {
"execa": "^7.1.1",
"fs-extra": "^11.1.1"
},
"engines": {
"node": ">= 18"
}
}
32 changes: 26 additions & 6 deletions docs/typedoc.config.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
{
"tsconfig": "../ember-resources/tsconfig.json",
"customCss": "./custom.css",
"compilerOptions": {
"noEmitOnError": false
},
"entryPoints": [
"../ember-resources/src/index.ts",
"../ember-resources/src/util/"
"../ember-resources/src"
],
"entryPointStrategy": "expand",
"navigationLinks": {
"Tutorial": "https://tutorial.glimdown.com",
"GitHub": "https://github.com/NullVoxPopuli/ember-resources"
},
"sidebarLinks": {
"link": "/utils/link/functions/link.html",
"service": "/utils/service/functions/service.html",
"keepLatest": "/utils/keepLatest/functions/keepLatest.html",
"fps": "/utils/fps/index.html",
"map": "/utils/map/functions/map.html",
"helper": "/utils/helper/functions/helper.html",
"remoteData": "/utils/remoteData/functions/RemoteData.html",
"debounce": "/utils/debounce/functions/debounce.html",
"emberConcurrency": "/utils/emberConcurrency/functions/trackedTask.html",
"trackedFunction": "/utils/function/functions/trackedFunction.html"
},
"entryPointStrategy": "resolve",
"readme": "../README.md",
"exclude": [],
"json": "./docs.json",
"out": "dist",
"emit": "docs",
"pretty": true,
"skipErrorChecking": true,
"excludePrivate": true,
"excludeProtected": false,
"excludeExternals": true,
"disableSources": true,
"searchInComments": true,
"disableSources": false,
"categorizeByGroup": false,
"plugin": [
]
"plugin": []
}
12 changes: 6 additions & 6 deletions ember-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/template": "^1.0.0-beta.3 || ^1.0.0",
"ember-async-data": "^1.0.0",
"ember-async-data": "^1.0.1",
"ember-concurrency": "^2.0.0",
"ember-source": "^3.28.0 || ^4.0.0 || ^5.0.0"
},
Expand All @@ -127,7 +127,7 @@
}
},
"devDependencies": {
"@babel/core": "7.21.3",
"@babel/core": "7.21.4",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.21.0",
Expand All @@ -153,7 +153,7 @@
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"concurrently": "^7.6.0",
"ember-async-data": "^1.0.0",
"ember-async-data": "^1.0.1",
"ember-source": "4.11.0",
"ember-template-lint": "5.7.1",
"eslint": "^8.35.0",
Expand All @@ -162,9 +162,9 @@
"prettier-plugin-ember-template-tag": "^0.3.2",
"rollup": "3.20.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-ts": "^3.0.0",
"tslib": "^2.4.0",
"typescript": "~5.0.0"
"rollup-plugin-ts": "^3.2.0",
"tslib": "^2.5.0",
"typescript": "~5.0.3"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
Loading

0 comments on commit 370976b

Please sign in to comment.