react-email
Advanced tools
Comparing version 1.8.1-canary.0 to 1.8.1-canary.1
{ | ||
"name": "react-email", | ||
"version": "1.8.1-canary.0", | ||
"version": "1.8.1-canary.1", | ||
"description": "A live preview of your emails right in your browser.", | ||
@@ -30,2 +30,5 @@ "bin": { | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
@@ -32,0 +35,0 @@ "@commander-js/extra-typings": "9.4.1", |
@@ -13,8 +13,11 @@ "use strict"; | ||
try { | ||
if (!fs_1.default.existsSync(dir)) { | ||
throw new Error(`Missing ${dir} folder`); | ||
} | ||
if (fs_1.default.existsSync(utils_1.REACT_EMAIL_ROOT)) { | ||
await (0, run_server_1.runServer)(dir, port); | ||
await (0, run_server_1.setupServer)('dev', dir, port); | ||
return; | ||
} | ||
await (0, utils_1.downloadClient)(); | ||
await (0, run_server_1.runServer)(dir, port); | ||
await (0, run_server_1.setupServer)('dev', dir, port); | ||
} | ||
@@ -21,0 +24,0 @@ catch (error) { |
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
const dev_1 = require("./commands/dev"); | ||
const preview_1 = require("./commands/preview"); | ||
const export_1 = require("./commands/export"); | ||
@@ -24,2 +25,12 @@ const constants_1 = require("./utils/constants"); | ||
extra_typings_1.program | ||
.command('build') | ||
.description('Builds a production preview app') | ||
.option('-d, --dir <path>', 'Directory with your email templates', './emails') | ||
.action(preview_1.buildPreview); | ||
extra_typings_1.program | ||
.command('start') | ||
.description('Starts the production build of the preview app') | ||
.option('-p --port <port>', 'Port to run production server on', '3000') | ||
.action(preview_1.startPreview); | ||
extra_typings_1.program | ||
.command('export') | ||
@@ -26,0 +37,0 @@ .description('Build the templates to the `out` directory') |
@@ -45,3 +45,3 @@ "use strict"; | ||
await fs_extra_1.default.ensureDir(path_1.default.join(constants_1.PACKAGE_PUBLIC_PATH, 'static')); | ||
const result = shelljs_1.default.cp('-r', path_1.default.join(emailDir, 'static'), path_1.default.join(constants_1.PACKAGE_PUBLIC_PATH)); | ||
const result = shelljs_1.default.cp('-r', path_1.default.join('static'), path_1.default.join(constants_1.PACKAGE_PUBLIC_PATH)); | ||
if (result.code > 0) { | ||
@@ -48,0 +48,0 @@ throw new Error(`Something went wrong while copying the file to ${path_1.default.join(emailDir, 'static')}, ${result.cat()}`); |
/** | ||
* Utility function to run init/sync for the server in dev, build or start mode. | ||
* | ||
* @param type dev | build | start | ||
* @param dir Directory in which the emails are located, only for dev and build, unused for start. | ||
* @param port The port on which the server will run, only for dev and start, unused for build. | ||
*/ | ||
export declare const runServer: (dir: string, port: string) => Promise<void>; | ||
export declare const setupServer: (type: 'dev' | 'build' | 'start', dir: string, port: string) => Promise<void>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.runServer = void 0; | ||
exports.setupServer = void 0; | ||
const watcher_1 = require("./watcher"); | ||
@@ -8,9 +11,12 @@ const detect_package_manager_1 = require("detect-package-manager"); | ||
const _1 = require("."); | ||
const path_1 = __importDefault(require("path")); | ||
const shelljs_1 = __importDefault(require("shelljs")); | ||
/** | ||
* Utility function to run init/sync for the server in dev, build or start mode. | ||
* | ||
* @param type dev | build | start | ||
* @param dir Directory in which the emails are located, only for dev and build, unused for start. | ||
* @param port The port on which the server will run, only for dev and start, unused for build. | ||
*/ | ||
const runServer = async (dir, port) => { | ||
const setupServer = async (type, dir, port) => { | ||
const cwd = await (0, find_root_1.findRoot)(_1.CURRENT_PATH).catch(() => ({ | ||
@@ -20,12 +26,24 @@ rootDir: _1.CURRENT_PATH, | ||
const emailDir = (0, _1.convertToAbsolutePath)(dir); | ||
const watcherInstance = (0, watcher_1.createWatcherInstance)(emailDir); | ||
const packageManager = await (0, detect_package_manager_1.detect)({ | ||
cwd: cwd.rootDir, | ||
}).catch(() => 'npm'); | ||
await (0, _1.generateEmailsPreview)(emailDir); | ||
await (0, _1.syncPkg)(); | ||
await (0, _1.installDependencies)(packageManager); | ||
(0, _1.startDevServer)(packageManager, port); | ||
(0, watcher_1.watcher)(watcherInstance, emailDir); | ||
// when starting, we dont need to worry about these because it should've already happened during the build stage. | ||
if (type !== 'start') { | ||
await (0, _1.generateEmailsPreview)(emailDir); | ||
await (0, _1.syncPkg)(); | ||
await (0, _1.installDependencies)(packageManager); | ||
} | ||
if (type === 'dev') { | ||
const watcherInstance = (0, watcher_1.createWatcherInstance)(emailDir); | ||
(0, _1.startDevServer)(packageManager, port); | ||
(0, watcher_1.watcher)(watcherInstance, emailDir); | ||
} | ||
else if (type === 'build') { | ||
(0, _1.buildProdServer)(packageManager); | ||
} | ||
else { | ||
shelljs_1.default.cd(path_1.default.join(_1.REACT_EMAIL_ROOT)); | ||
(0, _1.startProdServer)(packageManager, port); | ||
} | ||
}; | ||
exports.runServer = runServer; | ||
exports.setupServer = setupServer; |
{ | ||
"name": "react-email", | ||
"version": "1.8.1-canary.0", | ||
"version": "1.8.1-canary.1", | ||
"description": "A live preview of your emails right in your browser.", | ||
@@ -30,2 +30,5 @@ "bin": { | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
@@ -32,0 +35,0 @@ "@commander-js/extra-typings": "9.4.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29703
32
540