project-path-feat #7
@@ -0,0 +1,18 @@
|
|||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since this file overwrites environment variables from `config` lib.
|
||||||
|
* It's important to "import" this file before all scripts in entry point file, especially before `config`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
process.env.NODE_CONFIG_DIR = path.join(process.env.PROJECT_PATH ?? '', process.env.BLOCK_NAME ?? '', 'config');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export constant variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com';
|
||||||
|
export const IS_DEV = process.env.NODE_ENV === 'development';
|
||||||
|
export const BLOCK_NAME = process.env.BLOCK_NAME;
|
||||||
|
export const MODULE_PATH = process.env.MODULE_PATH ?? 'node_modules/block-dev-tool';
|
||||||
|
export const PROJECT_PATH = process.env.PROJECT_PATH ? path.join(process.env.PROJECT_PATH, BLOCK_NAME) : '';
|
||||||
+19
-21
@@ -1,4 +1,5 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import {BLOCK_NAME, IS_DEV, MODULE_PATH, PROJECT_PATH} from "./env.js";
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import {fileURLToPath} from 'url';
|
import {fileURLToPath} from 'url';
|
||||||
import memFs from 'mem-fs';
|
import memFs from 'mem-fs';
|
||||||
@@ -13,14 +14,11 @@ const __filename = fileURLToPath(import.meta.url);
|
|||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
export function getConfigs() {
|
export function getConfigs() {
|
||||||
const isDev = process.env.NODE_ENV === 'development'; // Check README file in case you get "missing files" error.
|
|
||||||
const developmentBlockName = process.env.BLOCK_NAME;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isDev,
|
isDev: IS_DEV,
|
||||||
developmentBlockName,
|
developmentBlockName: BLOCK_NAME,
|
||||||
modulesPath: process.env.MODULE_PATH ?? (isDev ? '' : 'node_modules/block-dev-tool'),
|
modulesPath: MODULE_PATH,
|
||||||
projectPath: process.env.PROJECT_PATH ?? (isDev ? path.join('blocks', developmentBlockName) : ''),
|
projectPath: PROJECT_PATH,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,19 +155,19 @@ export async function zipProject(srcDir, outputFileName = 'dist.zip') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function buildExportFiles(blockName, platform) {
|
export async function buildExportFiles(blockName, platform) {
|
||||||
if (platform.name.startsWith('wordpress')) {
|
if (platform.name.startsWith('wordpress')) {
|
||||||
if (platform.name === 'wordpress-acf-block') {
|
if (platform.name === 'wordpress-acf-block') {
|
||||||
await buildWordPress(blockName, {block: true});
|
await buildWordPress(blockName, {block: true});
|
||||||
} else if (platform.name === 'wordpress-elementor') {
|
} else if (platform.name === 'wordpress-elementor') {
|
||||||
await buildWordPress(blockName, {elementor: true});
|
await buildWordPress(blockName, {elementor: true});
|
||||||
} else if (platform.name === 'wordpress-component-manager') {
|
} else if (platform.name === 'wordpress-component-manager') {
|
||||||
await buildWordPress(blockName, {componentManager: true});
|
await buildWordPress(blockName, {componentManager: true});
|
||||||
} else {
|
} else {
|
||||||
await buildWordPress(blockName);
|
await buildWordPress(blockName);
|
||||||
}
|
|
||||||
} else if (platform.name === 'hubspot-email') {
|
|
||||||
await buildHubspotEmail(blockName)
|
|
||||||
} else if (platform.name === 'hubspot') {
|
|
||||||
await buildHubspotPage(blockName)
|
|
||||||
}
|
}
|
||||||
|
} else if (platform.name === 'hubspot-email') {
|
||||||
|
await buildHubspotEmail(blockName)
|
||||||
|
} else if (platform.name === 'hubspot') {
|
||||||
|
await buildHubspotPage(blockName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-6
@@ -7,13 +7,11 @@
|
|||||||
"url": "https://axe-web.com/"
|
"url": "https://axe-web.com/"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "component-dev",
|
|
||||||
"info": "node debug.js",
|
"info": "node debug.js",
|
||||||
"dev": "NODE_ENV=development NODE_CONFIG_DIR=blocks/header/config BLOCK_NAME=header node server.js",
|
"dev": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node server.js",
|
||||||
"build": "rollup --config rollup.config.js",
|
"build-platform": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node ./build.js",
|
||||||
"build-platform": "NODE_ENV=development NODE_CONFIG_DIR=blocks/header/config BLOCK_NAME=header node ./build.js",
|
"dev-dev-tool": "NODE_ENV=development rollup --config rollup.config.js --watch",
|
||||||
"build-platform-cli": "component-build",
|
"build-dev-tool": "rollup --config rollup.config.js"
|
||||||
"dev-js": "NODE_ENV=development rollup --config rollup.config.js --watch"
|
|
||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import {PRODUCTION_REGISTRY_URL} from "./env.js";
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
@@ -25,8 +26,6 @@ import PluginError from 'plugin-error';
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com';
|
|
||||||
|
|
||||||
const {isDev, modulesPath, projectPath, developmentBlockName} = getConfigs();
|
const {isDev, modulesPath, projectPath, developmentBlockName} = getConfigs();
|
||||||
const blocksRegistry = isDev ? 'http://localhost:3020' : PRODUCTION_REGISTRY_URL;
|
const blocksRegistry = isDev ? 'http://localhost:3020' : PRODUCTION_REGISTRY_URL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user