Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a script and files for running the manual testing app on a server #4719

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "add a script and files for running the manual testing app on a server",
"packageName": "@microsoft/fast-tooling",
"email": "[email protected]",
"dependentChangeType": "none"
}
15 changes: 15 additions & 0 deletions packages/tooling/fast-tooling/app/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var express = require("express");
var path = require("path");

// Create application
var app = express();

// Set public directory
var publicDir = path.resolve(__dirname);

// Set static application options
app.use("/", express.static(publicDir, { maxAge: "0d" }));

// Serve up application on specified port
var port = process.env.PORT || 7001;
app.listen(port);
9 changes: 9 additions & 0 deletions packages/tooling/fast-tooling/app/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

const appDir = path.resolve(__dirname, "./");
const outDir = path.resolve(__dirname, "../www");
Expand Down Expand Up @@ -89,5 +90,13 @@ module.exports = {
languages: ["html"],
features: ["format", "coreCommands", "codeAction"],
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "./server.js"),
to: path.resolve(__dirname, "../www/"),
},
],
}),
],
};
11 changes: 7 additions & 4 deletions packages/tooling/fast-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"types": "dist/dts/index.d.ts",
"scripts": {
"build": "yarn build:esm && yarn build:cjs && yarn build:message-system",
"build:app": "yarn build:message-system && webpack --progress --mode=production",
"build:esm": "tsc -p ./tsconfig.esm.json",
"build:cjs": "tsc -p ./tsconfig.cjs.json",
"build:message-system": "webpack --config webpack.message-system.config.js",
Expand Down Expand Up @@ -48,19 +49,23 @@
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/karma": "^5.0.0",
"@types/mocha": "^7.0.2",
"@types/lodash-es": "^4.17.4",
"@types/mocha": "^7.0.2",
"@types/node": "^9.6.7",
"ajv": "^6.10.0",
"chai": "^4.2.0",
"chai-spies": "^1.0.0",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^6.0.0",
"css-loader": "^4.2.0",
"eslint-config-prettier": "^6.10.1",
"express": "4.17.1",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^3.2.0",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"jsdom": "^16.2.2",
"jsdom-global": "3.0.2",
"karma": "^5.0.4",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.2",
Expand All @@ -72,8 +77,6 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"lodash-es": "4.17.15",
"jsdom": "^16.2.2",
"jsdom-global": "3.0.2",
"mdn-data": "^2.0.11",
"mini-css-extract-plugin": "^0.9.0",
"mocha": "^7.1.2",
Expand All @@ -95,8 +98,8 @@
"dependencies": {
"@microsoft/fast-colors": "^5.1.3",
"@microsoft/fast-components": "latest",
"@microsoft/fast-foundation": "latest",
"@microsoft/fast-element": "latest",
"@microsoft/fast-foundation": "latest",
"@microsoft/fast-web-utilities": "^4.7.3",
"vscode-html-languageservice": "^3.1.3"
}
Expand Down
49 changes: 25 additions & 24 deletions packages/tooling/fast-tooling/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,39 @@ const glob = require("glob");
const rootAppWebpackConfig = require(path.resolve(__dirname, "app/webpack.dev.js"));
const outDir = path.resolve(__dirname, "./www");

const configs = new Promise((resolver) => {
const configs = new Promise(resolver => {
try {
glob(`${path.resolve(__dirname, "./app/examples")}/*/webpack.dev.js`, {}, function (err, files) {
if (err) {
throw err;
}
glob(
`${path.resolve(__dirname, "./app/examples")}/*/webpack.dev.js`,
{},
function (err, files) {
if (err) {
throw err;
}

resolver(
files.map((file) => {
const webpackConfig = require(file);
const name = path.basename(path.dirname(file));
resolver(
files.map(file => {
const webpackConfig = require(file);
const name = path.basename(path.dirname(file));

webpackConfig.name = name;
webpackConfig.output = {
...webpackConfig.output,
path: path.resolve(outDir, name),
publicPath: `${name}/`,
}
webpackConfig.name = name;
webpackConfig.output = {
...webpackConfig.output,
path: path.resolve(outDir, name),
publicPath: `/${name}/`,
};

return webpackConfig;
})
);
});
return webpackConfig;
})
);
}
);
} catch (err) {
console.info(`No example app webpack files found`, err);
process.exit(0);
}
}).then((webpackConfigs) => {
return [
rootAppWebpackConfig,
...webpackConfigs
];
}).then(webpackConfigs => {
return [rootAppWebpackConfig, ...webpackConfigs];
});

module.exports = configs;
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8576,7 +8576,7 @@ copy-webpack-plugin@^5.1.1:
serialize-javascript "^4.0.0"
webpack-log "^2.0.0"

copy-webpack-plugin@^6.0.3, copy-webpack-plugin@^6.3.0:
copy-webpack-plugin@^6.0.0, copy-webpack-plugin@^6.0.3, copy-webpack-plugin@^6.3.0:
version "6.4.1"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-6.4.1.tgz#138cd9b436dbca0a6d071720d5414848992ec47e"
integrity sha512-MXyPCjdPVx5iiWyl40Va3JGh27bKzOTNY3NjUTrosD2q7dR/cLD0013uqJ3BpFbUjyONINjb6qI7nDIJujrMbA==
Expand Down Expand Up @@ -10858,7 +10858,7 @@ expect@^25.5.0:
jest-message-util "^25.5.0"
jest-regex-util "^25.2.6"

express@^4.16.3, express@^4.17.1:
express@4.17.1, express@^4.16.3, express@^4.17.1:
version "4.17.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
Expand Down