magicthing -> astro
This commit is contained in:
parent
af6b029e95
commit
47d1c22449
6 changed files with 28 additions and 1481 deletions
10
magicthing.mjs → astro.mjs
Normal file → Executable file
10
magicthing.mjs → astro.mjs
Normal file → Executable file
|
@ -14,16 +14,16 @@ if(!root) {
|
||||||
const fileProtocolRoot = `file://${root}/`;
|
const fileProtocolRoot = `file://${root}/`;
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const magicConfig = (await import(pathJoin(root, 'magicthing.config.mjs'))).default;
|
const astroConfig = (await import(pathJoin(root, 'astro.config.mjs'))).default;
|
||||||
magicConfig.projectRoot = new URL(magicConfig.projectRoot + '/', fileProtocolRoot);
|
astroConfig.projectRoot = new URL(astroConfig.projectRoot + '/', fileProtocolRoot);
|
||||||
magicConfig.hmxRoot = new URL(magicConfig.hmxRoot + '/', fileProtocolRoot);
|
astroConfig.hmxRoot = new URL(astroConfig.hmxRoot + '/', fileProtocolRoot);
|
||||||
|
|
||||||
|
|
||||||
// Should use an args parser eventually
|
// Should use an args parser eventually
|
||||||
if(process.argv.includes('--generate')) {
|
if(process.argv.includes('--generate')) {
|
||||||
return generate(magicConfig);
|
return generate(astroConfig);
|
||||||
} else {
|
} else {
|
||||||
return devServer(magicConfig);
|
return devServer(astroConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1471
package-lock.json
generated
1471
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
@ -1,16 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "hmx-v2",
|
"name": "astro",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Fred K. Schott",
|
"private": true,
|
||||||
|
"author": "Skypack",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./magicthing.mjs",
|
".": "./mastro.mjs",
|
||||||
"./snowpack-plugin": "./snowpack-plugin.cjs",
|
"./snowpack-plugin": "./snowpack-plugin.cjs",
|
||||||
"./h": "./lib/h.js",
|
"./h": "./lib/h.js",
|
||||||
"./render/preact": "./lib/render/preact.js"
|
"./render/preact": "./lib/render/preact.js"
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"astro": "astro.mjs"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && npm run copy-js",
|
"build": "tsc && npm run copy-js",
|
||||||
"copy-js": "copyfiles -u 1 src/*.js lib/"
|
"copy-js": "copyfiles -u 1 src/*.js lib/"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
export interface MagicConfigRaw {
|
export interface AstroConfigRaw {
|
||||||
dist: string;
|
dist: string;
|
||||||
projectRoot: string;
|
projectRoot: string;
|
||||||
hmxRoot: string;
|
hmxRoot: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MagicConfig {
|
export interface AstroConfig {
|
||||||
dist: string;
|
dist: string;
|
||||||
projectRoot: URL;
|
projectRoot: URL;
|
||||||
hmxRoot: URL;
|
hmxRoot: URL;
|
|
@ -1,4 +1,4 @@
|
||||||
import type { MagicConfig } from './@types/magicthing';
|
import type { AstroConfig } from './@types/astro';
|
||||||
import { loadConfiguration, startServer as startSnowpackServer } from 'snowpack';
|
import { loadConfiguration, startServer as startSnowpackServer } from 'snowpack';
|
||||||
import { existsSync, promises as fsPromises } from 'fs';
|
import { existsSync, promises as fsPromises } from 'fs';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
|
@ -11,8 +11,8 @@ const require = createRequire(import.meta.url);
|
||||||
const hostname = '127.0.0.1';
|
const hostname = '127.0.0.1';
|
||||||
const port = 3000;
|
const port = 3000;
|
||||||
|
|
||||||
export default async function(magicConfig: MagicConfig) {
|
export default async function(astroConfig: AstroConfig) {
|
||||||
const { projectRoot, hmxRoot } = magicConfig;
|
const { projectRoot, hmxRoot } = astroConfig;
|
||||||
|
|
||||||
const internalPath = new URL('./frontend/', import.meta.url);
|
const internalPath = new URL('./frontend/', import.meta.url);
|
||||||
const snowpackConfigPath = new URL('./snowpack.config.js', projectRoot);
|
const snowpackConfigPath = new URL('./snowpack.config.js', projectRoot);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { MagicConfig } from './@types/magicthing';
|
import type { AstroConfig } from './@types/astro';
|
||||||
import { loadConfiguration, startServer as startSnowpackServer } from 'snowpack';
|
import { loadConfiguration, startServer as startSnowpackServer } from 'snowpack';
|
||||||
import { promises as fsPromises } from 'fs';
|
import { promises as fsPromises } from 'fs';
|
||||||
import { relative as pathRelative } from 'path';
|
import { relative as pathRelative } from 'path';
|
||||||
|
@ -18,10 +18,10 @@ async function* allPages(root: URL): AsyncGenerator<URL, void, unknown> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function(magicConfig: MagicConfig) {
|
export default async function(astroConfig: AstroConfig) {
|
||||||
const { projectRoot, hmxRoot } = magicConfig;
|
const { projectRoot, hmxRoot } = astroConfig;
|
||||||
const pageRoot = new URL('./pages/', hmxRoot);
|
const pageRoot = new URL('./pages/', hmxRoot);
|
||||||
const dist = new URL(magicConfig.dist + '/', projectRoot);
|
const dist = new URL(astroConfig.dist + '/', projectRoot);
|
||||||
|
|
||||||
const configPath = new URL('./snowpack.config.js', projectRoot).pathname;
|
const configPath = new URL('./snowpack.config.js', projectRoot).pathname;
|
||||||
const config = await loadConfiguration({
|
const config = await loadConfiguration({
|
||||||
|
|
Loading…
Reference in a new issue