Skip to content

Commit 3f955c6

Browse files
author
Illia Obukhau
authored
[WC-1415]: Update momentjs in calendar web (#60)
2 parents c04eb9b + a8962ea commit 3f955c6

File tree

11 files changed

+2223
-219
lines changed

11 files changed

+2223
-219
lines changed

packages/customWidgets/calendar-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- Update moment.js to version 2.29.4
12+
913
## [1.0.13] - 2021-06-24
1014

1115
### Removed

packages/customWidgets/calendar-web/package.json

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,73 @@
11
{
22
"name": "calendar-web",
33
"widgetName": "Calendar",
4-
"version": "1.0.13",
4+
"version": "1.0.14",
55
"description": "Display and manage calendar events",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
7+
"license": "Apache-2.0",
78
"repository": {
89
"type": "git",
910
"url": "https://github.com/mendix/web-widgets.git"
1011
},
11-
"testProject": {
12-
"githubUrl": "https://github.com/mendix/testProjects",
13-
"branchName": "calendar-web"
12+
"mxpackage": {
13+
"name": "Calendar",
14+
"type": "widget",
15+
"mpkName": "Calendar.mpk"
1416
},
15-
"license": "Apache-2.0",
1617
"marketplace": {
1718
"minimumMXVersion": "7.14.1",
18-
"appNumber": 107954
19+
"appNumber": 107954,
20+
"appName": "Calendar"
21+
},
22+
"testProject": {
23+
"githubUrl": "https://github.com/mendix/testProjects",
24+
"branchName": "calendar-web"
1925
},
26+
"packagePath": "com.mendix.widget.custom",
2027
"scripts": {
21-
"start": "utils-react-widgets start",
22-
"dev": "utils-react-widgets dev",
23-
"format": "prettier --config \"../../prettier.config.js\" --write \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
24-
"test": "npm run test:unit",
25-
"test:unit": "jest --config ../../../scripts/test/jest.web.config.js",
26-
"pretest:e2e": "npm run release && node ../../../scripts/test/updateAtlas.js --latest-atlas",
27-
"test:e2e": "pluggable-widgets-tools test:e2e:web:cypress --remove-atlas-files",
28-
"test:e2e:local": "pluggable-widgets-tools test:e2e:web:cypress:local -- --config-file ../../../configs/e2e/cypress/cypress.json",
28+
"build": "ts-node --project scripts/tsconfig.json scripts/build.ts development",
29+
"create-gh-release": "rui-create-gh-release",
30+
"format": "pluggable-widgets-tools format",
2931
"lint": "eslint --config ../../../.eslintrc.js --ext .jsx,.js,.ts,.tsx src/",
30-
"lint:fix": "npm run lint -- --fix",
31-
"build": "utils-react-widgets build",
32-
"release": "utils-react-widgets release"
32+
"publish-marketplace": "rui-publish-marketplace",
33+
"release": "ts-node --project scripts/tsconfig.json scripts/build.ts production",
34+
"update-changelog": "rui-update-changelog-widget",
35+
"verify": "rui-verify-package-format"
3336
},
3437
"config": {
3538
"mendixHost": "http://localhost:8080",
3639
"developmentPort": 3000
3740
},
3841
"devDependencies": {
39-
"@mendix/custom-widgets-utils-internal": "workspace:*",
40-
"@mendix/pluggable-widgets-tools": ">=9.0.0",
41-
"@types/classnames": "^2.2.6",
42+
"@babel/core": "^7.20.2",
43+
"@mendix/pluggable-widgets-tools": "^9.18.0",
44+
"@mendix/release-utils-internal": "workspace:*",
4245
"@types/date-arithmetic": "^3.1.2",
46+
"@types/react": "^17.0.52",
4347
"@types/react-big-calendar": "0.20.20",
44-
"@types/react-dnd": "^3.0.2",
45-
"@types/react-dnd-html5-backend": "^3.0.2",
48+
"@types/react-dom": "^17.0.18",
49+
"babel-loader": "^8.2.1",
50+
"copy-webpack-plugin": "^11.0.0",
51+
"css-loader": "^6.7.2",
4652
"eslint": "^7.20.0",
47-
"jest": "^26.6.1"
53+
"fork-ts-checker-webpack-plugin": "^7.2.13",
54+
"jest": "^26.6.1",
55+
"mendix-client": "^7.15.8",
56+
"react": "~17.0.2",
57+
"react-dom": "~17.0.2",
58+
"sass": "^1.56.1",
59+
"sass-loader": "^13.2.0",
60+
"style-loader": "^3.3.1",
61+
"to-string-loader": "^1.1.6",
62+
"ts-loader": "^9.4.1",
63+
"typescript": "4.5.4",
64+
"webpack": "^5.3.2",
65+
"webpack-cli": "^4.1.0"
4866
},
4967
"dependencies": {
5068
"classnames": "^2.2.6",
5169
"date-arithmetic": "^3.1.0",
52-
"moment": "^2.24.0",
70+
"moment": "^2.29.4",
5371
"react-big-calendar": "0.19.2",
5472
"react-dnd": "2.6.0",
5573
"react-dnd-html5-backend": "^5.0.1"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { cp, mkdir, zip, exec } from "@mendix/release-utils-internal/shell";
2+
import { logStep, removeDist, runWidgetSteps, WidgetStepParams } from "@mendix/release-utils-internal/steps";
3+
import { dirname, join } from "node:path";
4+
5+
const [, , env] = process.argv;
6+
const isProd = env === "production";
7+
const copyToProject = !isProd && process.env.MX_PROJECT_PATH;
8+
9+
async function createMPK({ config }: WidgetStepParams): Promise<void> {
10+
logStep("Create mpk");
11+
const { paths, output } = config;
12+
mkdir("-p", dirname(output.files.mpk));
13+
await zip(join(paths.tmp, "widgets"), output.files.mpk);
14+
}
15+
16+
async function main(): Promise<void> {
17+
await runWidgetSteps({
18+
packagePath: process.cwd(),
19+
steps: [
20+
removeDist,
21+
async () => {
22+
logStep("Bundling");
23+
const wpc = isProd ? "webpack.config.prod.js" : "webpack.config.dev.js";
24+
await exec(`webpack -c ${wpc}`);
25+
},
26+
createMPK,
27+
async ({ config }) => {
28+
if (copyToProject) {
29+
logStep("Copy widget to targetProject");
30+
const dir = join(config.paths.targetProject, "widgets");
31+
mkdir("-p", dir);
32+
cp(config.output.files.mpk, dir);
33+
}
34+
}
35+
]
36+
});
37+
}
38+
39+
main().catch(err => {
40+
console.error(err);
41+
process.exit(1);
42+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@mendix/release-utils-internal/tsconfig"
3+
}

packages/customWidgets/calendar-web/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="Calendar2" version="1.0.13" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Calendar2" version="1.0.14" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="Calendar.xml" />
66
</widgetFiles>
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
{
2-
"extends": "@mendix/custom-widgets-utils-internal/configs/tsconfig.json",
2+
"include": ["./src", "./typings"],
33
"compilerOptions": {
4+
"noEmitOnError": true,
5+
"sourceMap": true,
6+
"module": "amd",
7+
"target": "es5",
8+
"lib": ["es2015", "dom"],
9+
"types": ["mendix-client", "jest"],
10+
"moduleResolution": "node",
11+
"declaration": false,
12+
"removeComments": true,
13+
"noLib": false,
14+
"watch": false,
15+
"forceConsistentCasingInFileNames": true,
16+
"noFallthroughCasesInSwitch": true,
17+
"noImplicitAny": true,
18+
"noImplicitReturns": true,
19+
"noImplicitThis": true,
20+
"skipLibCheck": true,
21+
"strictNullChecks": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
"jsx": "react",
25+
"jsxFactory": "createElement",
26+
"allowSyntheticDefaultImports": true,
27+
"esModuleInterop": true,
428
"baseUrl": ".",
529
"rootDir": "./",
630
"outDir": "dist/tsc/"
731
},
8-
"exclude": ["dist/", "tests/", "**/*.spec.ts", "node_modules/"]
32+
"exclude": ["dist/", "tests/", "**/*.spec.ts", "**/*.specs.ts", "node_modules/"]
933
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
const webpack = require("webpack");
2+
const { join, resolve } = require("path");
3+
const CopyWebpackPlugin = require("copy-webpack-plugin");
4+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
5+
const cwd = process.cwd();
6+
7+
const package = require(join(cwd, "package.json"));
8+
const widgetName = package.widgetName;
9+
const name = widgetName !== "RangeSlider" ? widgetName.toLowerCase() : widgetName;
10+
11+
const packageName = name;
12+
const mxHost = "http://localhost:8080";
13+
const developmentPort = "3000";
14+
15+
const widgetConfig = {
16+
context: cwd,
17+
entry: join(cwd, `src/components/${widgetName}Container.ts`),
18+
output: {
19+
path: resolve(cwd, "dist/tmp"),
20+
filename: chunkData => {
21+
const fileName = chunkData.chunk.name === "main" ? widgetName : "[name]";
22+
return `widgets/com/mendix/widget/custom/${name}/${fileName}.js`;
23+
},
24+
libraryTarget: "umd",
25+
publicPath: "/"
26+
},
27+
devServer: {
28+
compress: true,
29+
port: developmentPort,
30+
hot: true,
31+
proxy: [
32+
{
33+
target: mxHost,
34+
context: [`!/widgets/com/mendix/widget/custom/${name}/${widgetName}.ts`],
35+
onError(err, req, res) {
36+
if (res && res.writeHead) {
37+
res.writeHead(500, {
38+
"Content-Type": "text/plain"
39+
});
40+
if (err.code === "ECONNREFUSED") {
41+
res.end(
42+
"Please make sure that the Mendix server is running at " +
43+
mxHost +
44+
" or change the configuration \n " +
45+
"> npm config set " +
46+
packageName +
47+
":mendixhost http://host:port"
48+
);
49+
} else {
50+
res.end("Error connecting to Mendix server" + "\n " + JSON.stringify(err, null, 2));
51+
}
52+
}
53+
}
54+
}
55+
],
56+
stats: "errors-only"
57+
},
58+
resolve: {
59+
extensions: [".ts", ".js", ".tsx", ".jsx"],
60+
alias: {
61+
tests: resolve(cwd, "./tests")
62+
}
63+
},
64+
module: {
65+
rules: [
66+
{
67+
test: /\.tsx?$/,
68+
exclude: /node_modules/,
69+
use: [
70+
{
71+
loader: "ts-loader",
72+
options: {
73+
transpileOnly: true
74+
}
75+
}
76+
]
77+
},
78+
{
79+
test: /\.jsx?$/,
80+
exclude: /node_modules/,
81+
use: {
82+
loader: "babel-loader",
83+
options: {
84+
cacheDirectory: true,
85+
presets: ["@babel/preset-env", "@babel/preset-react"],
86+
plugins: [
87+
["@babel/plugin-proposal-class-properties", { loose: true }],
88+
["@babel/plugin-transform-react-jsx", { pragma: "createElement" }]
89+
]
90+
}
91+
}
92+
},
93+
{
94+
test: /\.(sa|sc|c)ss$/,
95+
use: [
96+
"style-loader",
97+
"css-loader",
98+
{
99+
loader: "sass-loader",
100+
options: {
101+
implementation: require("sass"),
102+
sassOptions: {
103+
fiber: false
104+
}
105+
}
106+
}
107+
]
108+
}
109+
]
110+
},
111+
mode: "development",
112+
devtool: "source-map",
113+
externals: ["react", "react-dom"],
114+
plugins: [
115+
new webpack.HotModuleReplacementPlugin(),
116+
new ForkTsCheckerWebpackPlugin(),
117+
new CopyWebpackPlugin({
118+
patterns: [
119+
{
120+
from: join(cwd, "src/**/*.xml").replace(/\\/g, "/"),
121+
toType: "template",
122+
to: "widgets/[name][ext]"
123+
}
124+
]
125+
})
126+
]
127+
};
128+
129+
const previewConfig = {
130+
entry: resolve(cwd, `./src/${widgetName}.webmodeler.ts`),
131+
output: {
132+
path: resolve(cwd, "dist/tmp"),
133+
filename: `widgets/${widgetName}.webmodeler.js`,
134+
libraryTarget: "commonjs"
135+
},
136+
resolve: {
137+
extensions: [".ts", ".js", ".tsx", ".jsx"]
138+
},
139+
module: {
140+
rules: [
141+
{
142+
test: /\.tsx?$/,
143+
loader: "ts-loader",
144+
options: {
145+
compilerOptions: {
146+
module: "CommonJS"
147+
}
148+
}
149+
},
150+
{
151+
test: /\.jsx?$/,
152+
exclude: /node_modules/,
153+
use: {
154+
loader: "babel-loader",
155+
options: {
156+
cacheDirectory: true,
157+
presets: ["@babel/preset-env", "@babel/preset-react"],
158+
plugins: [
159+
["@babel/plugin-proposal-class-properties", { loose: true }],
160+
["@babel/plugin-transform-react-jsx", { pragma: "createElement" }]
161+
]
162+
}
163+
}
164+
},
165+
{
166+
test: /\.(sa|sc|c)ss$/,
167+
use: ["to-string-loader", "css-loader", "sass-loader"]
168+
}
169+
]
170+
},
171+
mode: "development",
172+
externals: ["react", "react-dom"]
173+
};
174+
175+
module.exports = [widgetConfig, previewConfig];

packages/customWidgets/calendar-web/webpack.config.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { merge } = require("webpack-merge");
2-
const baseConfig = require("@mendix/custom-widgets-utils-internal/configs/webpack.config.dev");
2+
const baseConfig = require("./webpack.base.dev");
33

44
const overridingConfig = {
55
module: {

packages/customWidgets/calendar-web/webpack.config.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { merge } = require("webpack-merge");
2-
const baseConfig = require("@mendix/custom-widgets-utils-internal/configs/webpack.config.dev");
2+
const baseConfig = require("./webpack.base.dev");
33

44
const overridingConfig = {
55
module: {

0 commit comments

Comments
 (0)