Skip to content
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

Update tutorial to fix build #220

Merged
merged 7 commits into from
Feb 1, 2023
Merged
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
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
git config --global user.name "Tomster"
git config --global user.email "[email protected]"
- name: Set up Volta
uses: rwjblue/setup-volta@v1
uses: volta-cli/action@v4
- name: Set up build cache (yarn)
uses: actions/cache@preview
uses: actions/cache@v3
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install dependencies (apt-get)
run: |
sudo apt-get update -y
Expand Down Expand Up @@ -69,19 +69,19 @@ jobs:
working-directory: dist/code/super-rentals
run: git clean -dfX
- name: Upload artifacts (assets)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: assets (${{ matrix.channel }})
path: dist/assets
- name: Upload artifacts (markdown)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: markdown (${{ matrix.channel }})
path: dist/markdown
- name: Upload artifacts (code)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: code (${{ matrix.channel }})
Expand Down Expand Up @@ -142,12 +142,12 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y zipcmp advancecomp optipng perceptualdiff
- name: Download artifacts (assets)
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: assets (release)
path: assets
- name: Download artifacts (markdown)
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: markdown (release)
path: markdown
Expand Down Expand Up @@ -240,7 +240,7 @@ jobs:

git add public/images
- name: Upload artifacts (perceptualdiff)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: perceptualdiff (release)
Expand Down Expand Up @@ -305,7 +305,7 @@ jobs:
with:
ssh-private-key: ${{ secrets.SUPER_RENTALS_DEPLOY_KEY }}
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: code (release)
path: .
Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
with:
ssh-private-key: ${{ secrets.SUPER_RENTALS_DEPLOY_KEY }}
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: code (release)
path: output
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@
"private": true,
"devDependencies": {
"@actions/core": "^1.2.6",
"@types/glob": "^7.1.1",
"@types/image-size": "^0.7.0",
"@types/glob": "^8.0.0",
"@types/image-size": "^0.8.0",
"@types/mdast": "^3.0.2",
"@types/mkdirp": "^0.5.2",
"@types/mkdirp": "^1.0.2",
"@types/ncp": "^2.0.1",
"@types/node": "^12.7.2",
"@types/puppeteer": "^2.0.0",
"@types/node": "^18.11.18",
"@types/unist": "^2.0.3",
"@types/vfile": "^3.0.2",
"@types/vfile": "^4.0.0",
"chalk": "^2.4.2",
"ember-cli": "*",
"ember-dictionary": "^0.2.3",
"image-size": "^0.7.4",
"mkdirp": "^0.5.1",
"image-size": "^1.0.2",
"mkdirp": "^1.0.4",
"ncp": "^2.0.0",
"node-glob": "^1.2.0",
"puppeteer": "~2.1.1",
"puppeteer": "~19.5.2",
"rehype-stringify": "^6.0.0",
"remark": "^11.0.1",
"remark-cli": "^7.0.0",
Expand All @@ -46,9 +45,9 @@
"retext-syntax-urls": "^1.0.2",
"shx": "^0.3.2",
"ts-std": "^0.7.0",
"tslint": "^5.18.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.5.3",
"typescript": "^4.9.4",
"unified": "^8.4.0"
},
"scripts": {
Expand Down
9 changes: 4 additions & 5 deletions src/bin/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
writeFile as _writeFile
} from 'fs';
import _glob from 'glob';
import _mkdirp from 'mkdirp';
import mkdirp from 'mkdirp';
import { ncp as _ncp } from 'ncp';
import { basename, dirname, join, relative, sep } from 'path';
import frontmatter from 'remark-frontmatter';
Expand All @@ -21,7 +21,6 @@ import { doNotEdit, retinaImages, runCodeBlocks, todoLinks, zoeySays } from '../
const glob = promisify(_glob);
const readFile = promisify(_readFile);
const writeFile = promisify(_writeFile);
const mkdirp = promisify(_mkdirp);
const ncp = promisify(_ncp);

// 01-orientation.md -> orientation.md
Expand Down Expand Up @@ -55,8 +54,8 @@ async function main() {
let codeDir = join(project, 'dist', 'code');

await ncp(join(project, 'src', 'assets'), assetsDir);
await mkdirp(outDir);
await mkdirp(codeDir);
await mkdirp(outDir, {});
await mkdirp(codeDir, {});

let pattern = process.argv[2] || join('src', 'markdown', '**', '*.md');

Expand All @@ -79,7 +78,7 @@ async function main() {
let dir = unprefix(relative(srcDir, dirname(inputPath)));
let name = unprefix(basename(inputPath));

await mkdirp(join(outDir, dir));
await mkdirp(join(outDir, dir), {});

let outputPath = join(outDir, dir, name);

Expand Down
16 changes: 11 additions & 5 deletions src/lib/plugins/retina-images/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { exists as _exists } from 'fs';
import _imageSize from 'image-size';
import { HTML, Image } from 'mdast';
import { basename, resolve } from 'path';
import { expect } from 'ts-std';
import { promisify } from 'util';
import BaseWalker from '../../walker';
import Options from './options';
Expand Down Expand Up @@ -38,9 +39,14 @@ function attr(v: unknown): string {


async function toImgTag(node: Image, options: Options): Promise<HTML> {
let size = await imageSize(pathFor(node.url, options));
let width = Math.floor(size.width / 2);
let height = Math.floor(size.height / 2);
let sizeOfImage = await imageSize(pathFor(node.url, options));

let size = expect(sizeOfImage, 'size should be present');
let width = expect(size.width, 'width should be present');
let height = expect(size.height, 'height should be present');

let widthAttr = Math.floor(width / 2);
let heightAttr = Math.floor(height / 2);

let attrs = [];

Expand All @@ -54,8 +60,8 @@ async function toImgTag(node: Image, options: Options): Promise<HTML> {
attrs.push(`title=${attr(node.title)}`);
}

attrs.push(`width=${attr(width)}`);
attrs.push(`height=${attr(height)}`);
attrs.push(`width=${attr(widthAttr)}`);
attrs.push(`height=${attr(heightAttr)}`);

return {
type: 'html',
Expand Down
5 changes: 2 additions & 3 deletions src/lib/plugins/run-code-blocks/directives/file/copy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { lstat as _lstat, readFile as _readFile } from 'fs';
import { Code } from 'mdast';
import _mkdirp from 'mkdirp';
import mkdirp from 'mkdirp';
import { ncp as _ncp } from 'ncp';
import { basename, dirname, join } from 'path';
import { Option } from 'ts-std';
Expand All @@ -9,7 +9,6 @@ import Options from '../../options';
import parseArgs, { ToBool, optional, required } from '../../parse-args';

const lstat = promisify(_lstat);
const mkdirp = promisify(_mkdirp);
const ncp = promisify(_ncp);
const readFile = promisify(_readFile);

Expand Down Expand Up @@ -53,7 +52,7 @@ export default async function copyFile(node: Code, options: Options): Promise<Op
throw new Error(`\`${src}\` is neither a regular file or a directory`);
}

await mkdirp(destDir);
await mkdirp(destDir, {});
await ncp(src, destPath);

if (args.hidden) {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/plugins/run-code-blocks/directives/file/create.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { writeFile as _writeFile } from 'fs';
import { Code } from 'mdast';
import _mkdirp from 'mkdirp';
import mkdirp from 'mkdirp';
import { basename, dirname, join } from 'path';
import { Option } from 'ts-std';
import { promisify } from 'util';
import Options from '../../options';
import parseArgs, { ToBool, optional, required } from '../../parse-args';

const mkdirp = promisify(_mkdirp);
const writeFile = promisify(_writeFile);

interface Args {
Expand Down Expand Up @@ -37,7 +36,7 @@ export default async function createFile(node: Code, options: Options): Promise<

dir = join(dir, dirname(args.filename));

await mkdirp(dir);
await mkdirp(dir, {});

let path = join(dir, basename(args.filename));

Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/run-code-blocks/directives/pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Options from '../options';
async function prompt(message: string): Promise<void> {
console.log(`\n${message}\n`);

await new Promise(resolve => {
await new Promise<void>(resolve => {
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout
Expand Down
5 changes: 2 additions & 3 deletions src/lib/plugins/run-code-blocks/directives/screenshot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec as _exec } from 'child_process';
import { Code, Image } from 'mdast';
import _mkdirp from 'mkdirp';
import mkdirp from 'mkdirp';
import { basename, extname, join, sep } from 'path';
import { ScreenshotOptions, Viewport } from 'puppeteer';
import { JSONObject, JSONValue, assert } from 'ts-std';
Expand All @@ -10,7 +10,6 @@ import Options from '../options';
import parseArgs, { ToBool, optional, required } from '../parse-args';

const exec = promisify(_exec);
const mkdirp = promisify(_mkdirp);

interface Args {
filename: string;
Expand Down Expand Up @@ -156,7 +155,7 @@ export default async function screenshot(node: Code, options: Options, vfile: VF
filename = `${basename(filename, '.png')}@2x.png`;
}

await mkdirp(dir);
await mkdirp(dir, {});

let path = join(dir, filename);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/run-code-blocks/parse-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ToBool(input: string): boolean {
return input === 'true';
}

export type KeyTransforms = Array<KeyTransform<string | undefined, unknown>>;
export type KeyTransforms = KeyTransform<string | undefined, unknown>[];

export default function parseArgs<Args extends object>(node: Code, transforms: KeyTransforms): Args {
let { lang, meta } = node;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/run-code-blocks/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Server {
// TODO
}

get pid(): Option<number> {
get pid(): null | number | undefined {
return this.process && this.process.pid;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/zoey-says/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function isZoeySays({ children }: Blockquote): boolean {
firstParagraph.value === ZOEY_SAYS;
}

async function render(nodes: Array<BlockContent | DefinitionContent>, position?: Position): Promise<HTML> {
async function render(nodes: (BlockContent | DefinitionContent)[], position?: Position): Promise<HTML> {
let content = [];

for (let node of nodes) {
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/tutorial/part-1/01-orientation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ del package.json
@@ -9,2 +9,3 @@
EmberENV: {
+ RAISE_ON_DEPRECATION: true,
FEATURES: {
EXTEND_PROTOTYPES: false,
```

```run:file:create hidden=true cwd=super-rentals filename=public/_redirects
Expand Down
5 changes: 5 additions & 0 deletions src/markdown/tutorial/part-2/11-ember-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ During this refactor, you will learn about:
* The Ember Data store
* Working with adapters and serializers

```run:file:create hidden=true cwd=super-rentals filename=app/adapters/application.js
export { default } from '@ember-data/adapter/json-api';
```

## What is Ember Data?

Now that we've added some features, it's time to do some clean up again!
Expand Down Expand Up @@ -82,6 +86,7 @@ Attributes declared with the `@attr` decorator work with the auto-track feature
```run:command hidden=true cwd=super-rentals
ember test --path dist
git add app/models/rental.js
git add app/adapters/application.js
```

## Testing Models
Expand Down
Loading