tl; dr版本 - 我想在我的应用程序的页脚上显示生产应用程序的部署日期,以便用户确切知道应用程序上次更新的时间.
我希望它是自动的,但我想不出一种方法来捕获构建期间的当前日期时间,然后将其解析为html(jsx)来显示它们.
更新 - 顺便说一句,我使用CRA,并没有计划从它弹出!至少不是为了这个.
上下文 - 为什么我要这个? 我在React中有一个生产应用程序,我没有不受限制的访问权限.在那里提出了一些问题,我能够在我的dev上复制它,我修复了问题并进行了部署(或者我以为我做了).但是问题仍然存在于生产中,经过更长时间的调试后,我只是要求他们提供大量的诊断信息,以检查生产API或数据库是否有问题等.但最终证明我的生产部署不是'成功了.我想如果我在应用程序的某个地方展示了最后一个部署日期时间,我可以向用户询问,而不是深入了解详细的诊断信息.
我正在使用dotenv来存储环境变量,并且自从将其包含在gemfile中以来,就无法将其推送到heroku。我收到以下错误:
remote: -----> Installing node-v6.10.0-linux-x64
remote: -----> Detecting rake tasks
remote: sh: 2: Syntax error: Unterminated quoted string
remote: sh: 2: Syntax error: Unterminated quoted string
remote: !
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! rake aborted!
remote: ! NameError: uninitialized constant Dotenv
remote: ! /tmp/build_5437bc300afb80cfa46b1111bb960f46/config/application.rb:17:in `<top (required)>'
remote: ! /tmp/build_5437bc300afb80cfa46b1111bb960f46/Rakefile:4:in `require_relative'
remote: ! …Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 11 项目,其中使用 AWS Amplify ( aws-amplify v3.3.26) 并使用 Cognito 用户池来管理用户。我已经设置了托管 UI,但没有使用任何自定义属性。一切正常,我已在用户池的用户属性中选择了读写权限的所有属性。
我使用以下代码来获取 cognitoUser 对象:-
Auth.currentAuthenticatedUser()
.then((currentUser) => {
console.log('The currentUser => ', currentUser);
Auth.currentUserInfo()
.then((res) => {
console.log('Here are the current user info! =>', res);
})
.catch((err) => {
console.log('Current user info failed to fetch', err);
});
})
.catch((err) => {
console.log(err);
});
return;
}
Run Code Online (Sandbox Code Playgroud)
根据AWS Amplify 文档,我应该能够在 cognitoUser 对象中获取正确的属性。但我不明白。
这就是我得到的全部(另请注意,会话为空,不确定这意味着什么):-

正如您所看到的,对象中没有“attributes”键。
我还注意到有一个Auth.currentUserInfo()可用的方法,而我的控制台日志只会产生一个空对象。
正如您在此处看到的,我已为用户池客户端定义中的所有属性设置了所有必需的权限,并且没有任何自定义属性:-

目前,我将姓名和电子邮件存储为必需属性,并且所有用户都拥有该属性。但我无法访问它。我能够看到深度嵌套在 cognitoUser 对象 ( cognitoUser.signInUserSession.idToken.payload.email) 中的电子邮件,但仍然找不到 name 属性。我想获取列出当前用户所有可用属性的整个属性对象。
我缺少什么?
我运行rspec时收到此警告: -
DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.
Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }
New keyword style:
get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
session: nil # Can safely be omitted.
(called from block (4 levels) in <top (required)> at /home/user/organization/fooobarr/spec/controllers/contacts_controller_spec.rb:13)
Run Code Online (Sandbox Code Playgroud)
这是我的控制器规格: - …