test-day-106

Today’s Task

  • [ASAP] Property Page
    • Basic functionality
    • Search History
    • clickable GUI

Additional Task

Thought

1

component audit 编译一份 jar 包出来试试看

2

Release Script migrating progress

  • access
  • catalog
  • crypto
  • customerportal
  • dynamic-config-ui
  • hyas
  • kakapo
  • keymaster
  • liquibase-deploy
  • nam
  • nexus
  • nucleussolr
  • playercard
  • playerownership-cassandra
  • playerownership
  • porpoise
  • saola
  • sloth
  • tos
  • vaquita

test-day-105

Today’s Task

  • [ASAP] Property Page
    • basic functionality
  • Merge Lockbox Building Scripts to CM-Release

Additional Task

Thought

1

Vite 为什么可以做到比 CRA 快那么多!

原理是什么!

2

long term task

migrate image building scripts

catalog -> LB series -> nexus and nucleus

3

CTRL + X 会导致当前数字减一

CTRL + A 会加一

找了好久的 tcp connection refused 原来是手滑触发了 vim 插件的快捷键…

test-day-104

Today’s Task

  • [ASAP] Property Page

Additional Task

  • Remove service worker
  • Port Catalog Release Script to CM-Release
  • Fix RleaseMe Frontend ENVs

Thought

1

Jenkins pipeline 里面,SCM 虽然可以设置很多个 repo

但似乎并不能让每个 repository checkout 到 不同的 branch 下

原本 release image 脚本就在当前 workspace 里,所以其实只需要指定一次 branch 就可以了

但是集中移到另一个 repo 里之后,

终究还是用 bash 脚本手动 git 了

test-day-103

Today’s Task

  • [ASAP] Property Page
  • Migrate ReleaseMe from CRA to Vite
    • npm run build

Additional Task

  • Migrate Code Merge to cm-release

Thought

1

爬了一上午 github issues 才发现

原来组里大神在另一个项目里已经给出解决方案了

换哪个包用都写清楚了

后面就可以专心 Fix String Refs 了

写得优雅一些吧

2

踩了一大堆坑

但其实还是半懂不懂的感觉

比如说 NODE_ENV 我只是简单地把 REACT_APP_NODE_ENV 名字替换成了 VITE_NODE_ENV,大概是会有问题的

test-day-102

Today’s Task

  • [ASAP] Property Page
  • Migrate ReleaseMe from CRA to Vite
    • npm run build
    • Fix String Refs

Additional Task

Thought

1

折腾了好久迁移至 Vite

ESM 和 CJS 之间的相爱相杀

奇奇怪怪的 TS 类型体操?

花了很多时间在尝试上,

但如果以后编译都会快三倍

那还是值得的

vite-migration-notes

1 Safe-Buffer Undefined

1
2
index.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'from')
at node_modules/safe-buffer/index.js (index.js:12:12)
1
npm i buffer

2. util.inherits is not a function

1
2
Uncaught TypeError: util.inherits is not a function
at node_modules/jws/lib/data-stream.js (data-stream.js:39:6)

util is a node builtin module and isn’t/won’t get polyfilled by vite
you will need to add polyfills for node builtins

1
2
npm i util
npm i inherits-browser
1
2
3
4
Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at Object.inherits (inherits_browser.js:6:31)
at node_modules/jws/lib/data-stream.js (data-stream.js:39:6)

do several mock ups in vite.config.ts

1
2
3
4
5
6
7
define:{
'process.env': process.env,
},resolve: {
alias: {
inherits: './inherits.js',
}
}

and then create ./inherits.js

1
2
3
4
5
6
7
8
9
10
11
12
13
function inherits(ctor, superCtor) {
if (!superCtor.prototype) return
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true,
},
})
}
module.exports = inherits

3. crypto has been externalized for browser compatibility

1
2
3
4
Uncaught (in promise) Error: Module "crypto" has been externalized for browser compatibility and cannot be accessed in client code.
at Object.get (__vite-browser-external:crypto:3:11)
at Function.jumpToOKTA (Jwt.ts:49:42)
at App.componentDidMount (App.tsx:20:17)

4. react-router & vite ts error

1
2
3
node_modules/react-router/index.d.ts:151:74 - error TS1110: Type expected.

node_modules/vite/types/customEvent.d.ts:2:60 - error TS1110: Type expected.

Upgraded Typescript from 3.9 to the latest 4.5.4

5. TS2794

1
2
3
src/Components/Layout/FlowPlayground.tsx:75:101 - error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?

75 await new Promise((resolve, _) => filter.setState({ statusFilter: FlowStatus.Focus }, () => resolve()));

6. TS2571

1
2
3
src/Model/Requests.tsx:130:33 - error TS2571: Object is of type 'unknown'.

130 let promise = await ex.json();

in tsconfig.json, set useUnknownInCatchVariables to false

7. Could not resolve ‘./lib/sign-{}’ from ./lib/sign-{}?commonjs-external

1
2
3
4
5
6
7
8
Could not resolve './lib/sign-{}' from ./lib/sign-{}?commonjs-external
error during build:
Error: Could not resolve './lib/sign-{}' from ./lib/sign-{}?commonjs-external
at error (C:\Users\yunhaoliu\Projects\releaseme\frontend\node_modules\rollup\dist\shared\rollup.js:158:30)
at ModuleLoader.handleResolveId (C:\Users\yunhaoliu\Projects\releaseme\frontend\node_modules\rollup\dist\shared\rollup.js:22384:24)
at C:\Users\yunhaoliu\Projects\releaseme\frontend\node_modules\rollup\dist\shared\rollup.js:22363:26
[!] Error: unfinished hook action(s) on exit:
(vite:load-fallback) load "C:/Users/yunhaoliu/Projects/releaseme/frontend/node_modules/antd/node_modules/rc-tree-select/es/utils/strategyUtil.js"

remove stream: {}, global: {}, process: {} in vite.config.ts which seemed to be mock ups of node builtin modules

8. Module is not defined

1
2
Uncaught ReferenceError: module is not defined
<anonymous> http://local-releaseme.citools.ea.com:8080/assets/vendor.9c99dfbb.js:169

没啥办法了 换包吧

注释掉 JWT 的部分之后就过了,所以可以锁定问题出在 JWT 上

看了眼 node_modules 里的 JWT,确实就在这里

modules.export 看到这个心里就抖三抖

试着用了 import filter,没什么效果

最坏情况是自己重写一份支持 ESM 的 JWT

最后是换了 jwt-decode

9. Cannot find namespace ‘NodeJS’

1
2
3
4
5
6
7
8
9
10
11
12
13
src/Components/Controls/LoadingComponent.tsx:13:20 - error TS2503: Cannot find namespace 'NodeJS'.

13 loadingNumber: NodeJS.Timeout | null = null;
~~~~~~

src/Model/Jwt.ts:3:20 - error TS2307: Cannot find module 'crypto' or its corresponding type declarations.

3 import crypto from 'crypto'
~~~~~~~~


Found 2 errors.

in tsconfig.json , add

1
2
3
"types":[
"node"
]

10. index.af9a4108.js:3 Uncaught (in promise) TypeError: rt.randomBytes is not a function

1
index.af9a4108.js:3 Uncaught (in promise) TypeError: rt.randomBytes is not a function

终究是用 crypto-js 绕过去了

test-day-101

Today’s Task

  • [ASAP] Property Page
  • Migrate ReleaseMe from CRA to Vite
    • Transfered config files
    • Mock up Node builtin modules
    • npm start

Additional Task

  • Rebuild image for Shadowbroker
  • Fix email sending on Node B
  • Release image for Nexus and initialize regresion

Thought

1

Migrate CRA to Vite

1 Update package.json

1
2
3
4
5
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},

delete react-scripts from dependencies

install several vite devDependencies

1
npm i vite @vitejs/plugin-react vite-plugin-svgr

2 Add Vite Config

vite.config.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgrPlugin from 'vite-plugin-svgr'
// import reactJsx from 'vite-react-jsx'

export default defineConfig({
build: {
outDir: 'build',
},
plugins: [react(),
svgrPlugin({
svgrOptions: {
icon: true
}
})]
})

3. Update tsconfig.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["./src"]
}

then npm i or yarn

4. Move index.html out

move /public/index.html to the root of the project

Remove %PUBLIC_URL%

Add script

1
2
3
4
5
  <body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>

5. Update ENV vars

search and replace all process.env.REACT_APP_ to import.meta.env.VITE_

test-day-100

Today’s Task

  • [ASAP] Comment Time
  • [ASAP] Property Page

Additional Task

  • Rebuild images for solr serires
  • Check missing components for CHG0157114
  • Add saola to hadar script

Thought

1

下午四点左右会昏过去

试着站起来、喝水、走动走动

都不行

要提前准备好咖啡

2

React Router 默认用到是 v6, 而 Fastrun 用的是 v5

然后我这发现 switch 都没法用……

大致就是在等 npm run build 的一分半里昏过去了

用仅存的意识提交了 MR,还改了改 hadar 脚本

test-day-99

Today’s Task

  • [ASAP] Comment Time
  • [ASAP] Property Page

Additional Task

  • Fix Audit Tool
  • Fix Component Audit
  • Fix Component Audit v4
  • Create build jobs

Thought

1

property page 和 comment time 写的实在太慢了

不熟悉呀

2

三个 audit 全挂了

两个是因为 Jenkins Job 的 Branch 设置原因,填 origin/master 就好了,否则会去找 InfractionLedger 的 master branch

sox audit 就很离谱,Cassandra Contactpoint 炸了,不仅仅是 9042 端口没法访问,这台机器本身就连不上去……

1
2
3
4
5
21:34:17.000 [main] INFO  com.soxaudit.SoxauditApplication - Starting SoxauditApplication v0.0.1-SNAPSHOT with PID 15872 (/root/audittool/soxaudit.jar started by root in /home/shdev/pct/jenkins/workspace/audit_tool/sox-audit/soxaudit)
21:34:17.006 [main] DEBUG com.soxaudit.SoxauditApplication - Running with Spring Boot v2.1.1.RELEASE, Spring v5.1.3.RELEASE
21:34:17.008 [main] INFO com.soxaudit.SoxauditApplication - No active profile set, falling back to default profiles: default
21:34:27.610 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitTools': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'recordService': Unsatisfied dependency expressed through field 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'recordDAO': Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/soxaudit/db/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.core.CassandraAdminTemplate]: Factory method 'cassandraTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/soxaudit/db/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'session' defined in class path resource [com/soxaudit/db/config/CassandraConfig.class]: Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /10.86.32.167:9042 (com.datastax.driver.core.exceptions.TransportException: [/10.86.32.167:9042] Cannot connect))

3

中午试着趴了一会,没有睡着

反而又把自己拖进了深渊里

深海下一片漆黑的感觉

甚至还有压强

4

LB jobs 迁移 ASAP

原来的机器用了 4~5 年,随时可能会挂

而且 windows 的 Jenkins 会跑起来非常慢

Build Jobs -> OneCase -> INTBVT -> BVT's -> Docker Deploy

5

为啥这个 Ant Button 会换行啊啊啊啊啊啊

<List.Item> 里面会有一个 <List.Item.Meta>,这里面的 AntButton 如果后面没有跟着的 content 就会和 description 一行,

如果有跟着 content 就会换行

我想让它在表格右上角

如果写在 <List.Item> 标签里面的 extra 属性里,也会换行…

最离谱的是文档的 SandBox 里面,是在右上角,并不会换行。

然后发现有一个叫 itemLayout 的属性,可以设置成 horizontal 或者 vertical

改成了 vertical 就好了……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
renderCommentRecords(flow: Flow): ReactNode{
return (
<Descriptions.Item label="Comment" span={4}>
{
<List className="demo-loadmore-list"
itemLayout="horizontal"
locale={ { emptyText: "No comment yet" } }
dataSource={flow.comment_records}
renderItem={comment =>
<List.Item
extra={
<AntButton type="link">
Delete
</AntButton>
}
>
<List.Item.Meta
avatar={<Avatar src={comment.avatarURL} size="large" />}
title={comment.user_email}
description={ comment.createTime.format() }
// description={comment.content}
/>
{ comment.user_email !== Request.user ? null :
<AntButton type="link" onClick={() => this.deleteComment(comment)}>
Delete
</AntButton>}
{ comment.content }
{ comment.user_email !== Request.user ? null :
<AntButton type="link" onClick={() => this.deleteComment(comment)}>
Delete
</AntButton>
}
{ comment.content}
</List.Item>
}
/>
}
<Comment content={<>
<Form<CommentRecord> ref={this.form} onFinish={values => this.postComment(values, flow)}>
<Form.Item name="content">
<TextArea rows={4}/>
</Form.Item>
<Form.Item style={ {textAlign: "center" } }>
<AntButton type="link" htmlType="submit" loading={this.state.commentButtonLoading}>
Add Comment
</AntButton>
</Form.Item>
</Form>
</>}
/>
</Descriptions.Item>
)
}

test-day-98

Today’s Task

  • [urgent] Upload db.data onto artifactory
  • [ASAP] Comment time
  • [ASAP] Property page

Additional Task

  • Track Nexus-ui regression low passrate
  • Rebuild image for customizedlog.
  • Send Test Failure Email

Thought

1

突然发现一整天不看手机也是一件需要挑战的事情了

我 不 对 劲

要踏踏实实去做事情才行

试了很多花哨的解决方案

种树,秒表,番茄钟……

最有效的还是直接丢进包里,眼不见为净

2

Target: deploy db.data’s binary onto ATF

those jar files after mvn clean install?

liquibase.data uploads them without UploadBinary Job

这是在哪里触发的 upload to artifactory??

maven deploy 的时候做的

所以看了一整个上午,答案已经呼之欲出了吧

release_job.sh 里面会根据当前 product 去找到对应的目录进去 mvn -e -q clean deploy 一把

在 pom.xml 里面设置一下 <distributionManagement>,脚本里加上判断,执行一下命令就 ok 了

1
2
3
4
5
6
7
8
9

<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal Repo Name</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>

3

终究还是在一个只有两个页面的项目里加入了 React Router (霰弹枪警告

4

还是要用 Jira 去追踪自己的 Task

这样自己博客上的 daily task,就真的可以是认真打算今天做的事情,

进一步细化以后更容易执行

也就更不容易去咕咕咕

5

回想起了 10 年晚上在世博轴上奔跑的感觉

那时觉得身边的一切都如此新奇

半梦半醒间又想起了更早的感觉

08年的夏天,阁楼亭子间

CRT,时之笛