Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

put env replace in corejam rollup #471

Merged
merged 13 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ jobs:
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
cd packages/auth
API_ORIGIN=http://localhost:3000 yarn static -l
JWT_HASH=test FAKER_MODULE=auth DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd ../../test/cypress
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/plugins/auth/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
Expand Down Expand Up @@ -161,8 +162,9 @@ jobs:
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
cd packages/dershop
cp .env.sample .env
yarn corejam generateSchema && yarn corejam bootstrap
API_ORIGIN=http://localhost:3000 yarn static -l
yarn static -l
JWT_HASH=test FAKER_MODULE=auth DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/plugins/dershop/**/*"
env:
Expand Down Expand Up @@ -202,8 +204,10 @@ jobs:
yarn bs
cd examples
yarn corejam createApp test
cd test && yarn static
DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd ../../test/cypress
cd test
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
Expand Down Expand Up @@ -246,8 +250,11 @@ jobs:
cd ../rollup-plugin && yarn link
cd ../core-components && yarn link
cd /github/home && corejam createApp test
cd test && yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin && yarn static
DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd /__w/corejam/corejam/test/cypress
cd test
yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd /__w/corejam/corejam/test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
Expand Down Expand Up @@ -291,8 +298,10 @@ jobs:
cd ../core-components && yarn link
cd /github/home && cp -r $CLI_PATH . && cd cli && yarn link @corejam/base --ignore-scripts && yarn --ignore-scripts
cd /github/home && /github/home/cli/dist/index.js createApp test
cd test && yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin && yarn static
DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd /__w/corejam/corejam/test/cypress
cd test && yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd /__w/corejam/corejam/test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
Expand Down
4 changes: 3 additions & 1 deletion packages/auth/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ MAIL_SES_SECRET_ACCESS_KEY=
MAIL_SMTP_HOST=
MAIL_SMTP_PORT=
MAIL_SMTP_USER=
MAIL_SMTP_PASS=
MAIL_SMTP_PASS=

POSTCSS_BROWSERS="last 4 version"
5 changes: 4 additions & 1 deletion packages/auth/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www"],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
2 changes: 0 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
],
"devDependencies": {
"@corejam/cli": "0.0.25",
"@rollup/plugin-replace": "2.4.1",
"@stencil/react-output-target": "0.0.9",
"@types/bcryptjs": "2.4.2",
"@types/faker": "5.1.7",
"@types/jsonwebtoken": "8.5.0",
"args": "5.0.1",
"dotenv": "8.2.0",
"shx": "0.3.3",
"ts-sinon": "2.0.1",
"tslib": "2.1.0",
Expand Down
9 changes: 1 addition & 8 deletions packages/auth/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require("dotenv").config();
import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -16,12 +14,7 @@ const config: Config = {
port: 3001,
},
outputTargets: [],
plugins: [
replace({
"process.env.API_ORIGIN": JSON.stringify(process.env.API_ORIGIN),
}),
corejam(),
],
plugins: corejam(),
rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down
9 changes: 9 additions & 0 deletions packages/canvas/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
2 changes: 0 additions & 2 deletions packages/canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
"@corejam/cli": "0.0.25",
"@corejam/core-components": "0.0.28",
"@corejam/rollup-plugin": "0.0.7",
"@rollup/plugin-replace": "2.4.1",
"@stencil/core": "2.4.0",
"@stencil/react-output-target": "0.0.9",
"@types/faker": "5.1.7",
"dotenv": "8.2.0",
"faker": "5.4.0",
"tslib": "2.1.0",
"typescript": "4.2.3"
Expand Down
11 changes: 2 additions & 9 deletions packages/canvas/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
require("dotenv").config();

import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -20,12 +17,8 @@ const config: Config = {
port: 3001,
},
outputTargets: [],
plugins: [
replace({
"process.env.API_ORIGIN": JSON.stringify(process.env.API_ORIGIN),
}),
corejam(),
],
plugins: corejam(),

rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/helpers/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const packageJson = (mono = false) => `{
"@corejam/run": "${mono ? require("../../../run/package.json").version : "latest"}",
"@corejam/rollup-plugin": "${mono ? require("../../../rollup-plugin/package.json").version : "latest"}",
"faker": "5.1.0",
"dotenv": "8.2.0",
"@rollup/plugin-replace": "2.3.4",
"@stencil/react-output-target": "0.0.9",
"@stencil/core": "2.4.0",
"rollup-plugin-node-polyfills": "0.2.1"
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/templates/plugin/.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DEPLOYMENT_URL=http://localhost:3000
API_ORIGIN=http://localhost:3000
POSTCSS_BROWSERS="last 4 version"
10 changes: 1 addition & 9 deletions packages/cli/src/templates/plugin/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
require("dotenv").config();

import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -17,12 +14,7 @@ const config: Config = {
port: 3001,
},
outputTargets: [],
plugins: [
replace({
"process.env.API_ORIGIN": JSON.stringify(process.env.API_ORIGIN),
}),
corejam(),
],
plugins: corejam(),
rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down
5 changes: 4 additions & 1 deletion packages/core-components/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www"],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
5 changes: 5 additions & 0 deletions packages/core-components/app/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const env = {
NODE_ENV: process.env.NODE_ENV,
POSTCSS_BROWSERS: process.env.POSTCSS_BROWSERS || "last 4 version",
API_ORIGIN: process.env.API_ORIGIN || "",
};
3 changes: 2 additions & 1 deletion packages/core-components/app/store/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { Build } from "@stencil/core";
import { createStore } from "@stencil/store";
import { sha256 } from "crypto-hash";
import { Components } from "../components";
import { env } from "../env";
import { FlashEvent, FlashTypes } from "../utils/events";

let client;

if (Build.isBrowser) {
const httpLink = createHttpLink({
uri: (process.env.API_ORIGIN ?? "") + "/api/graphql",
uri: env.API_ORIGIN + "/api/graphql",
credentials: "include",
useGETForQueries: true,
});
Expand Down
5 changes: 3 additions & 2 deletions packages/core-components/app/utils/style.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import autoprefixer from "autoprefixer";
import postcss from "postcss";
import { env } from "../env";
import { computeStyle } from "./computeStyle";
import { propertyToTransformer } from "./transformerMap";
import { addStyleTagToHead, generateHash, lowercaseFirstLetter, uppercaseFirstLetter } from "./utils";

const stylesCache = new Map();

export const DEFAULT_BROWSERS = [process.env.POSTCSS_BROWSERS || "last 4 version"];
export const DEFAULT_BROWSERS = [env.POSTCSS_BROWSERS];

const params = { overrideBrowserslist: DEFAULT_BROWSERS, grid: "autoplace" };

Expand Down Expand Up @@ -87,7 +88,7 @@ export const calculateStyles = async (instance) => {
}
const computedStyleString = computeStyle(collectedStyles, hash);

if (process.env.NODE_ENV === "development") {
if (env.NODE_ENV === "development") {
const finalResult = computedStyleString;
stylesCache.set(hash, finalResult);
addStyleTagToHead(finalResult, hash);
Expand Down
2 changes: 0 additions & 2 deletions packages/core-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
"@corejam/cli": "0.0.25",
"@corejam/rollup-plugin": "0.0.7",
"@corejam/run": "0.0.12",
"@rollup/plugin-replace": "2.4.1",
"@stencil/core": "2.4.0",
"@stencil/react-output-target": "0.0.9",
"@stencil/store": "1.4.1",
"@types/faker": "5.1.7",
"@xstate/fsm": "1.6.0",
"autoprefixer": "10.2.5",
"crypto-hash": "1.3.0",
"dotenv": "8.2.0",
"graphql-tag": "2.11.0",
"postcss": "8.2.7",
"rollup-plugin-node-polyfills": "0.2.1",
Expand Down
9 changes: 1 addition & 8 deletions packages/core-components/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require("dotenv").config();
import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -16,12 +14,7 @@ const config: Config = {
port: 3001,
},
outputTargets: [],
plugins: [
replace({
"process.env.POSTCSS_BROWSERS": JSON.stringify(process.env.POSTCSS_BROWSERS),
}),
corejam(),
],
plugins: corejam(),
rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down
1 change: 1 addition & 0 deletions packages/dershop/.env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
API_ORIGIN=http://localhost:3000
JWT_HASH=jwthash
POSTCSS_BROWSERS="last 4 version"
5 changes: 4 additions & 1 deletion packages/dershop/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www", "static", "_tmp_"],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
2 changes: 0 additions & 2 deletions packages/dershop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@
],
"devDependencies": {
"@corejam/cli": "0.0.25",
"@rollup/plugin-replace": "2.4.1",
"@stencil/react-output-target": "0.0.9",
"@types/faker": "5.1.7",
"args": "5.0.1",
"dotenv": "8.2.0",
"jest-date-mock": "1.0.8",
"shx": "0.3.3",
"tslib": "2.1.0",
Expand Down
12 changes: 2 additions & 10 deletions packages/dershop/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
require("dotenv").config();

import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -18,13 +15,8 @@ const config: Config = {
logRequests: true,
},
outputTargets: [],
plugins: [
replace({
"process.env.API_ORIGIN": JSON.stringify(process.env.API_ORIGIN),
"process.env.POSTCSS_BROWSERS": JSON.stringify(process.env.POSTCSS_BROWSERS),
}),
corejam(),
],
plugins: corejam(),

rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down
4 changes: 4 additions & 0 deletions packages/notify/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
3 changes: 2 additions & 1 deletion packages/p2p/.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DEPLOYMENT_URL=http://localhost:3000
DEPLOYMENT_URL=http://localhost:3000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEPLOYMENT_URL=http://localhost:3000
API_ORIGIN=http://localhost:3000

POSTCSS_BROWSERS="last 4 version"
9 changes: 9 additions & 0 deletions packages/p2p/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var path = require("path");

module.exports = {
extends: [path.join(__dirname, "../../.eslintrc.js")],
ignorePatterns: ["web-components", "react", "www", "server", "tests", "cli", "app/env.ts", "stencil.config.ts"],
rules: {
"no-process-env": 2
}
};
2 changes: 0 additions & 2 deletions packages/p2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
"@corejam/core-components": "0.0.28",
"@corejam/rollup-plugin": "0.0.7",
"@corejam/run": "0.0.12",
"@rollup/plugin-replace": "2.4.1",
"@stencil/core": "2.4.0",
"@stencil/react-output-target": "0.0.9",
"@types/faker": "5.1.7",
"dotenv": "8.2.0",
"faker": "5.4.0",
"tslib": "2.1.0",
"typescript": "4.2.3"
Expand Down
10 changes: 1 addition & 9 deletions packages/p2p/stencil.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
require("dotenv").config();

import corejam from "@corejam/rollup-plugin";
import replace from "@rollup/plugin-replace";
import { Config } from "@stencil/core";
import { reactOutputTarget } from "@stencil/react-output-target";
import fs from "fs";
Expand All @@ -17,12 +14,7 @@ const config: Config = {
port: 3001,
},
outputTargets: [],
plugins: [
replace({
"process.env.API_ORIGIN": JSON.stringify(process.env.API_ORIGIN),
}),
corejam(),
],
plugins: corejam(),
rollupPlugins: {
after: [nodePolyfills()],
},
Expand Down