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

feat: automate migration from v1 to v2 #3015

Merged
merged 76 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
350751c
add poc for migration tool
Jun 29, 2020
c9825ca
fix version
Jun 29, 2020
1af40d5
fix path
Jun 29, 2020
f3ef7d7
fix some type error
Jun 30, 2020
2899a57
fix type errors
Jun 30, 2020
ff69e5c
fix commad
Jun 30, 2020
82fd083
delete package.lock.json
anshulrgoyal Jun 30, 2020
ce46ff0
ignore lib folder in eslint
Jun 30, 2020
16fcb8a
ignore lib in prettier
Jun 30, 2020
b94f826
fix missing version
Jun 30, 2020
329c122
fix sidebar in next
Jun 30, 2020
8dec62b
Merge branch 'master' into anshul/migration
anshulrgoyal Jun 30, 2020
5cb7076
use primaey color
Jun 30, 2020
137fc99
fix navbar link
Jun 30, 2020
0b63d49
fix footer
Jun 30, 2020
17a4d3e
sanatize front-matter for gray-matter
Jul 1, 2020
29119fd
add e2e test
Jul 2, 2020
0de0d74
fixworkflow
Jul 2, 2020
47a15c6
add unit test
Jul 3, 2020
a58345f
chore(v2): fix eslint error
teikjun Jul 6, 2020
8064587
refactor(v2): use descriptive variable names
teikjun Jul 6, 2020
e0e88d1
refactor(v2): refactor createProjectStructure
teikjun Jul 6, 2020
b2b1efb
refactor(v2): refactor migrateDocusaurusProject
teikjun Jul 6, 2020
baa647c
refactor(v2): fix eslint errors
teikjun Jul 6, 2020
3fd9b7f
refactor code
anshulrgoyal Jul 6, 2020
69376c3
fix(v2): fix mistake
teikjun Jul 6, 2020
6ca86aa
fix a mistake
teikjun Jul 6, 2020
2698a0a
use path.join
Jul 6, 2020
c578843
remove console.log
Jul 6, 2020
5470ce2
try automate migrating md file to mdx
Jul 9, 2020
aa023ec
fix types not found
Jul 9, 2020
455010c
fix types
Jul 9, 2020
0ba5f09
remove unused fixture
Jul 9, 2020
0454fd3
use package.json for version
Jul 15, 2020
ebb89a8
add support for pages
Jul 20, 2020
fd41ed9
Merge branch 'master' of github.com:MLH-Fellowship/docusaurus into an…
Jul 20, 2020
91d1c8f
add support
Jul 20, 2020
4fd4e00
sanitize fortmatter only in case of special character
Jul 20, 2020
f35fd45
chore(v2): add color to dependencies
teikjun Jul 21, 2020
71c2d4a
feat(v2): initialize config with range of color and add logs
teikjun Jul 21, 2020
07ce46b
chore(v2): add glob dependency
teikjun Jul 21, 2020
b5f4d27
fix(v2): fix color generation
teikjun Jul 21, 2020
d09805d
fix(v2): fix type issue
teikjun Jul 21, 2020
263fc9d
feat(v2): add all unknown fields to customFields
teikjun Jul 21, 2020
8fd179e
fix(v2): fix css mistake
teikjun Jul 21, 2020
fd52b71
fix lerna
Jul 21, 2020
6d071de
fix(v2): fix github actions
teikjun Jul 21, 2020
884be0a
feat(v2): add option flag for migrating pages
teikjun Jul 21, 2020
335e4e9
fix special character
Jul 21, 2020
bf0670f
remove depulicate build
Jul 21, 2020
05d6bb7
fix test
Jul 21, 2020
b02021c
remove unwanted file
Jul 22, 2020
a5e8717
fix frontmatter
Jul 22, 2020
409a9c2
remove unused file
Jul 22, 2020
ca1f0af
rerun the test
Jul 22, 2020
c481ed7
fix links
Jul 23, 2020
5d243f8
feat(v2): filter out more fields from customFields
teikjun Jul 23, 2020
aaefc7d
merge master
Jul 23, 2020
1be33e6
feat(v2): filter out deprecated fields from customFields
teikjun Jul 23, 2020
2e4bc14
fix items
Jul 23, 2020
ab5a2b0
fix types
Jul 23, 2020
9b9ea6c
Merge branch 'master' of github.com:facebook/docusaurus into anshul/m…
Jul 23, 2020
43cddab
merge master
Jul 23, 2020
b33f9e9
Merge branch 'teikjun/migration' of github.com:MLH-Fellowship/docusau…
teikjun Jul 23, 2020
4ffaec8
revert docs
Jul 23, 2020
9625055
Merge branch 'anshul/migration' of github.com:MLH-Fellowship/docusaur…
teikjun Jul 23, 2020
4e06a4b
fix doc
Jul 23, 2020
a2c4df9
fix broken link
Jul 23, 2020
4e67050
fix test
Jul 23, 2020
ba6dea6
test
Jul 23, 2020
837cde2
fix ci
Jul 23, 2020
78cd0a4
fix ci
Jul 23, 2020
925adf1
fix ci
Jul 23, 2020
3a3dc69
fix ci
Jul 24, 2020
b6bfe61
fix frontmatter
Jul 24, 2020
c42af01
log custom fields
Jul 24, 2020
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ packages/docusaurus-plugin-sitemap/lib/
packages/docusaurus-plugin-ideal-image/lib/
packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js
packages/docusaurus-theme-classic/lib/
packages/docusaurus-migrate/lib/

packages/docusaurus-1.x/.eslintrc.js
packages/docusaurus-init/templates/facebook/.eslintrc.js
36 changes: 36 additions & 0 deletions .github/workflows/migration-cli-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: MIGRATION CLI E2E TEST

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Installation
run: yarn
- name: Migrate D1 website
run: yarn docusaurus-migrate migrate ./website-1.x ./test-migrated
- name: Install in Test website
run: yarn
working-directory: test-migrated
- name: Build Test website
run: yarn build
working-directory: test-migrated
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ packages/docusaurus-plugin-debug/lib/
packages/docusaurus-plugin-sitemap/lib/
packages/docusaurus-plugin-ideal-image/lib/
packages/docusaurus-theme-classic/lib/
packages/docusaurus-migrate/lib/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ packages/docusaurus-plugin-content-pages/lib/
packages/docusaurus-plugin-debug/lib/
packages/docusaurus-plugin-sitemap/lib/
packages/docusaurus-plugin-ideal-image/lib/
packages/docusaurus-migrate/lib/
packages/docusaurus-theme-classic/lib/
__fixtures__
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ignorePatterns = [
'/packages/docusaurus-plugin-content-blog/lib',
'/packages/docusaurus-plugin-content-docs/lib',
'/packages/docusaurus-plugin-content-pages/lib',
'/packages/docusaurus-migrate/lib',
];

module.exports = {
Expand Down
60 changes: 60 additions & 0 deletions packages/docusaurus-migrate/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env node

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const chalk = require('chalk');
const semver = require('semver');
const cli = require('commander');
const path = require('path');

const requiredVersion = require('../package.json').engines.node;

const {migrateDocusaurusProject, migrateMDToMDX} = require('../lib');

function wrapCommand(fn) {
return (...args) =>
fn(...args).catch((err) => {
console.error(chalk.red(err.stack));
process.exitCode = 1;
});
}

if (!semver.satisfies(process.version, requiredVersion)) {
console.log(
chalk.red(`\nMinimum Node version not met :(`) +
chalk.yellow(
`\n\nYou are using Node ${process.version}. We require Node ${requiredVersion} or up!\n`,
),
);
process.exit(1);
}

cli
.command('migrate [siteDir] [newDir]')
.option('--mdx', 'Try to migrate MD to MDX too')
.option('--page', 'Try to migrate pages too')
.description('Migrate between versions of docusaurus website')
.action((siteDir = '.', newDir = '.', {mdx, page}) => {
const sitePath = path.resolve(siteDir);
const newSitePath = path.resolve(newDir);
wrapCommand(migrateDocusaurusProject)(sitePath, newSitePath, mdx, page);
});

cli
.command('mdx [siteDir] [newDir]')
.description('Migrate markdown files to MDX')
.action((siteDir = '.', newDir = '.') => {
const sitePath = path.resolve(siteDir);
const newSitePath = path.resolve(newDir);
wrapCommand(migrateMDToMDX)(sitePath, newSitePath);
});
cli.parse(process.argv);

if (!process.argv.slice(2).length) {
cli.outputHelp();
}
12 changes: 12 additions & 0 deletions packages/docusaurus-migrate/external_types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

declare module '@mapbox/hast-util-to-jsx';

declare module 'hast-util-to-string';

declare module 'color';
Loading