chore(cli): remove "rocket init" command

This commit is contained in:
Thomas Allmer
2022-08-20 20:50:12 +02:00
parent 8b48fb9760
commit 57ec19fecc
21 changed files with 0 additions and 562 deletions

View File

@@ -2,7 +2,6 @@
import { Command } from 'commander';
import { RocketStart } from './RocketStart.js';
import { RocketBuild } from './RocketBuild.js';
import { RocketInit } from './RocketInit.js';
import { RocketUpgrade } from './RocketUpgrade.js';
import { RocketPreview } from './RocketPreview.js';
// import { ignore } from './images/ignore.js';
@@ -180,7 +179,6 @@ export class RocketCli {
let pluginsMeta = [
{ plugin: RocketStart, options: {} },
{ plugin: RocketBuild, options: {} },
{ plugin: RocketInit, options: {} },
// { plugin: RocketLint },
{ plugin: RocketUpgrade, options: {} },
{ plugin: RocketPreview, options: {} },

View File

@@ -1,86 +0,0 @@
import path from 'path';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';
export class RocketInit {
/**
* @param {import('commander').Command} program
* @param {import('./RocketCli.js').RocketCli} cli
*/
async setupCommand(program, cli) {
this.cli = cli;
program
.command('init')
.option(
'-o, --output-dir <path>',
'path to where to put the source files [default to current directory]',
)
.action(async cliOptions => {
// cli.setOptions(cliOptions);
this.outputDir = cliOptions.outputDir ? path.resolve(cliOptions.outputDir) : process.cwd();
await this.init();
});
}
async init() {
if (!this.outputDir) {
return;
}
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
const initFilesDir = path.join(moduleDir, 'init-files');
const packageJsonPath = path.join(this.outputDir, 'package.json');
if (!(await fs.pathExists(packageJsonPath))) {
await fs.writeJson(packageJsonPath, {});
}
await fs.copy(initFilesDir, this.outputDir, {
errorOnExist: true,
filter: file => !(file.endsWith('_gitignore') || file.endsWith('README.md')),
});
const packageJson = await fs.readJson(packageJsonPath);
await fs.writeJson(
packageJsonPath,
{
...packageJson,
type: 'module',
scripts: {
...packageJson.scripts,
start: 'NODE_DEBUG=engine:rendering rocket start --open',
build: 'NODE_DEBUG=engine:rendering rocket build',
},
imports: {
'#images/*': './docs/__shared/*',
},
exports: {
'.': './src/index.js',
},
},
{ spaces: 2 },
);
const gitignorePath = path.join(this.outputDir, '.gitignore');
await fs.ensureFile(gitignorePath);
await fs.appendFile(
gitignorePath,
await fs.readFile(path.join(initFilesDir, '_gitignore'), 'utf8'),
);
const readmePath = path.join(this.outputDir, 'README.md');
await fs.ensureFile(readmePath);
await fs.appendFile(
readmePath,
await fs.readFile(path.join(initFilesDir, '_gitignore'), 'utf8'),
);
console.log('All files have been created 🎉');
console.log('Start developing by running `npm start`');
process.exit(0);
}
}

View File

@@ -1,10 +0,0 @@
{
"gitdoc.enabled": false,
"typescript.tsdk": "node_modules/typescript/lib",
"files.exclude": {
"**/*-mdjs-generated.js": true,
},
"search.exclude": {
"**/*-mdjs-generated.js": true,
}
}

View File

@@ -1,9 +0,0 @@
# Welcome to Rocket
Get started with
```bash
npm start
```
Create new pages by calling them `my-page.rocket.md` and by putting them into `docs/`.

View File

@@ -1,8 +0,0 @@
## npm
node_modules
npm-debug.log
## Rocket ignore files
*-mdjs-generated.js
_site
_site-dev

View File

@@ -1,6 +0,0 @@
import { rocketLaunch } from '@rocket/launch';
export default /** @type {import('@rocket/cli').RocketCliOptions} */ ({
absoluteBaseUrl: 'http://localhost:8080',
presets: [rocketLaunch()],
});

View File

@@ -1,29 +0,0 @@
```js server
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '10--guides/10--first-pages/10--getting-started.rocket.md';
import { pageTree, layout, html } from '../../recursive.data.js';
export { pageTree, layout, html };
/* END - Rocket auto generated - do not touch */
```
# Getting Started
Rocket has the following prerequisites:
- [Node 14+](https://nodejs.org/en/)
Make sure they are installed before proceeding.
## Setup
The fastest way to get started is by using an existing preset like the launch preset.
<inline-notification type="warning">
If you don't want to use the `module` package type, make sure to rename the generated config file to `rocket.config.mjs`.
</inline-notification>
```js script
import '@rocket/launch/inline-notification/inline-notification.js';
```

View File

@@ -1,24 +0,0 @@
```js server
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '10--guides/10--first-pages/20--custom-layout.rocket.md';
import { pageTree } from '../../recursive.data.js';
export { pageTree };
/* END - Rocket auto generated - do not touch */
import { html } from 'lit';
export const layout = data => html`
<html>
<head></head>
<body>
<p>A FULLY custom layout</p>
${data.content()}
<a href="../index.rocket.md">Go back to Guides</a>
</body>
</html>
`;
```
# Custom Layout
Here is my markdown content.

View File

@@ -1,43 +0,0 @@
```js server
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '10--guides/10--first-pages/20--images.rocket.md';
import { pageTree, layout, html } from '../../recursive.data.js';
export { pageTree, layout, html };
/* END - Rocket auto generated - do not touch */
```
# Images
We can add a private package import to your
👉 `package.json`
```json
"imports": {
"#images/*": "./docs/__shared/*"
},
```
With that we can then use `resolve:[[npm resolve name]]` in our urls.
```md
![rocket image](resolve:#images/rocket-image.jpg)
```
<div style="width: 50%">
![rocket image](resolve:#images/rocket-image.jpg)
</div>
You can also include images from dependencies.
```md
![astronaut](resolve:@rocket/launch/assets/404/astronaut.svg)
```
<div style="width: 50%">
![astronaut](resolve:@rocket/launch/assets/404/astronaut.svg)
</div>

View File

@@ -1,12 +0,0 @@
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '10--guides/10--first-pages/index.rocket.js';
import { pageTree, layout } from '../../recursive.data.js';
export { pageTree, layout };
/* END - Rocket auto generated - do not touch */
import { html } from 'lit';
export default () => html`
<h1>First Pages</h1>
<meta name="menu:exclude" content="true" />
`;

View File

@@ -1,17 +0,0 @@
```js server
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '10--guides/index.rocket.md';
import { pageTree, layout, html } from '../recursive.data.js';
export { pageTree, layout, html };
/* END - Rocket auto generated - do not touch */
import { ChildListMenu } from '@rocket/engine';
```
# Learning Rocket
<meta name="menu:link.text" content="Guides">
Rocket helps you generate static pages from Markdown files while giving you the flexibility to sprinkle in some JavaScript where needed.
${pageTree.renderMenu(new ChildListMenu(), sourceRelativeFilePath)}

View File

@@ -1,16 +0,0 @@
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '20--docs/index.rocket.js';
import { pageTree, layout, html } from '../recursive.data.js';
export { pageTree, layout, html };
/* END - Rocket auto generated - do not touch */
import { ChildListMenu } from '@rocket/engine';
export default () => html`
<meta name="menu:link.text" content="Docs" />
<h1>Documentation</h1>
<p>Here you will find all the details for each of the packages/systems we offer.</p>
${pageTree.renderMenu(new ChildListMenu(), sourceRelativeFilePath)}
`;

View File

@@ -1,21 +0,0 @@
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '20--docs/star-wars.rocket.js';
import { pageTree, layout, html } from '../recursive.data.js';
export { pageTree, layout, html };
/* END - Rocket auto generated - do not touch */
import cache from '@11ty/eleventy-cache-assets';
const films = await cache('https://swapi.dev/api/films/', {
duration: '1d',
type: 'json',
});
export default () => html`
<h1>Star Wars</h1>
<h2>Films:</h2>
<ul>
${films.results.map(film => html`<li>${film.title} (${film.release_date})</li>`)}
</ul>
`;

View File

@@ -1,11 +0,0 @@
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = '404.html.rocket.js';
import { pageTree, html } from './recursive.data.js';
export { pageTree, html };
/* END - Rocket auto generated - do not touch */
import { Layout404 } from '@rocket/launch';
export const layout = new Layout404();
export default () => '';

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,45 +0,0 @@
export const footerMenu = [
{
name: 'Discover',
children: [
{
text: 'Blog',
href: '/blog/',
},
{
text: 'Help and Feedback',
href: 'https://github.com/modernweb-dev/rocket/issues',
},
],
},
{
name: 'Follow',
children: [
{
text: 'GitHub',
href: 'https://github.com/modernweb-dev/rocket',
},
{
text: 'Twitter',
href: 'https://twitter.com/modern_web_dev',
},
{
text: 'Slack',
href: '/about/slack/',
},
],
},
{
name: 'Support',
children: [
{
text: 'Sponsor',
href: '/about/sponsor/',
},
{
text: 'Contribute',
href: 'https://github.com/modernweb-dev/rocket/blob/main/CONTRIBUTING.md',
},
],
},
];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

View File

@@ -1,52 +0,0 @@
/* START - Rocket auto generated - do not touch */
export const sourceRelativeFilePath = 'index.rocket.js';
import { pageTree } from './recursive.data.js';
export { pageTree };
/* END - Rocket auto generated - do not touch */
import { html } from 'lit';
import { LayoutHome } from '@rocket/launch';
import { footerMenu } from './__shared/footerMenu.js';
export const layout = new LayoutHome({
pageTree,
footerMenu,
slogan: 'The modern web setup for static sites with a sprinkle of JavaScript.',
callToActionItems: [
{ text: 'Follow Guides', href: '/guides/' },
{ text: 'Browse Docs', href: '/docs/' },
],
background: '/home-background.svg',
reasonHeader: 'Why Rocket?',
reasons: [
{
header: 'Small',
text: 'No overblown tools or frontend frameworks, add JavaScript and/or Web Components only on pages where needed.',
},
{
header: 'Pre-Rendered',
text: 'Statically generated content means less JavaScript to ship and process.',
},
{
header: 'Zero Configuration',
text: 'Automatic code splitting, filesystem based routing, and JavaScript in Markdown.',
},
{
header: 'Meta Framework',
text: html`Build on top of giants like <a href="https://www.11ty.dev/">Eleventy</a>,
<a href="https://rollupjs.org/">Rollup</a>, and
<a href="https://www.modern-web.dev/">Modern Web</a>.`,
},
{
header: 'Powerful Default Template',
text: 'Provide content and you are ready to go.',
},
{
header: 'Ready for Production',
text: 'Optimized for a smaller build size, faster dev compilation and dozens of other improvements.',
},
],
});
export default () => '';

View File

@@ -1,121 +0,0 @@
{
"title": "Rocket | Rocket",
"h1": "Rocket",
"name": "Rocket",
"menuLinkText": "Rocket",
"url": "/",
"outputRelativeFilePath": "index.html",
"sourceRelativeFilePath": "index.rocket.js",
"level": 0,
"children": [
{
"title": "Learning Rocket | Rocket",
"h1": "Learning Rocket",
"headlinesWithId": [
{
"text": "Learning Rocket",
"id": "learning-rocket",
"level": 1
}
],
"menuLinkText": "Guides",
"name": "Learning Rocket",
"url": "/guides/",
"outputRelativeFilePath": "guides/index.html",
"sourceRelativeFilePath": "10--guides/index.rocket.md",
"level": 1,
"children": [
{
"title": "First Pages | Rocket",
"h1": "First Pages",
"menuNoLink": true,
"name": "First Pages",
"menuLinkText": "First Pages",
"url": "/guides/first-pages/",
"outputRelativeFilePath": "guides/first-pages/index.html",
"sourceRelativeFilePath": "10--guides/10--first-pages/index.rocket.js",
"level": 2,
"children": [
{
"title": "Getting Started | Rocket",
"h1": "Getting Started",
"headlinesWithId": [
{
"text": "Getting Started",
"id": "getting-started",
"level": 1
},
{
"text": "Setup",
"id": "setup",
"level": 2
}
],
"name": "Getting Started",
"menuLinkText": "Getting Started",
"url": "/guides/first-pages/getting-started/",
"outputRelativeFilePath": "guides/first-pages/getting-started/index.html",
"sourceRelativeFilePath": "10--guides/10--first-pages/10--getting-started.rocket.md",
"level": 3
},
{
"h1": "Custom Layout",
"headlinesWithId": [
{
"text": "Custom Layout",
"id": "custom-layout",
"level": 1
}
],
"name": "Custom Layout",
"menuLinkText": "Custom Layout",
"url": "/guides/first-pages/custom-layout/",
"outputRelativeFilePath": "guides/first-pages/custom-layout/index.html",
"sourceRelativeFilePath": "10--guides/10--first-pages/20--custom-layout.rocket.md",
"level": 3
},
{
"title": "Images | Rocket",
"h1": "Images",
"headlinesWithId": [
{
"text": "Images",
"id": "images",
"level": 1
}
],
"name": "Images",
"menuLinkText": "Images",
"url": "/guides/first-pages/images/",
"outputRelativeFilePath": "guides/first-pages/images/index.html",
"sourceRelativeFilePath": "10--guides/10--first-pages/20--images.rocket.md",
"level": 3
}
]
}
]
},
{
"title": "Documentation | Rocket",
"menuLinkText": "Docs",
"h1": "Documentation",
"name": "Documentation",
"url": "/docs/",
"outputRelativeFilePath": "docs/index.html",
"sourceRelativeFilePath": "20--docs/index.rocket.js",
"level": 1,
"children": [
{
"title": "Star Wars | Rocket",
"h1": "Star Wars",
"name": "Star Wars",
"menuLinkText": "Star Wars",
"url": "/docs/star-wars/",
"outputRelativeFilePath": "docs/star-wars/index.html",
"sourceRelativeFilePath": "20--docs/star-wars.rocket.js",
"level": 2
}
]
}
]
}

View File

@@ -1,16 +0,0 @@
import { PageTree } from '@rocket/engine';
import { LayoutSidebar } from '@rocket/launch';
import { footerMenu } from './__shared/footerMenu.js';
import { html } from 'lit';
export const pageTree = new PageTree({
inputDir: new URL('./', import.meta.url),
outputDir: new URL('../_site', import.meta.url),
});
await pageTree.restore();
export const layout = new LayoutSidebar({ pageTree, footerMenu });
export { html };
// export const openGraphLayout = new OpenGraphLayoutLogo();

View File

@@ -1,33 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"outDir": "./dist-types",
"rootDir": ".",
"composite": true,
"allowJs": true,
"checkJs": true,
"emitDeclarationOnly": true,
"target": "esnext",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"downlevelIteration": true,
"strict": true,
"moduleResolution": "Node",
"typeRoots": ["@types", "./types"],
"types": ["node"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": false,
"forceConsistentCasingInFileNames": true,
"lib": [
"DOM",
"DOM.Iterable",
"ES6",
"ES2017",
// Allows array.flatMap. import `array-flat-polyfill` to cover node10
"ES2019.array",
"ScriptHost"
]
}
}