Angular PWA missing ngsw.json and ngsw-worker file - progressive-web-apps

I have a problem with #angular/pwa. when I am building in production mode I am not getting ngsw-worker.js and ngsw.json files in my dist folder.
the pwa version am using is:
#angular/pwa: ^0.13.8
#angular/service-worker: ~7.1.0
#angular version 7
Thanks in advance

This answer is only relevant when:
you use nrwl/nx
which decorates the ng command
and angular configuration composition:
i.e. ng build client --configuration=production,variant
nx version 11
Now the workaround for version 10 (see below) does not work anymore!
closed-nx#4296: Cannot pass in multiple configurations using -c since nx 11
actual fix should be handled in: nx#2839: NX does not handle multiple configurations: nx run app:build --configuration=production,stage-env
a workaround can be to opt-out of the nx ng-cli-decorate patch
quote from nx#4452:
To opt out of this patch:
Replace occurrences of nx with ng in your package.json Remove the
script from your postinstall script in your package.json Delete and
reinstall your node_modules
nx version 10
To fix the issue (we use nx version 10) we replaced:
ng build client --configuration=production,variant with
nx build client -c=production,variant
The problem was, that nx did not pass the configuration correctly to ng and thus ng did not build the production configuration (thus no PWA/service-worker)
Links to nx issues:
#2839: NX does not handle multiple configurations: nx run app:build --configuration=production,stage-env
#4296: Cannot pass in multiple configurations using -c since nx 11

You can copy the files from the node_modules folder (from a prompt in your project folder):
cp node_modules/#angular/service-worker/ngsw-worker.js ./src/ngsw-worker.js
cp node_modules/#angular/service-worker/ngsw-config.json ./ngsw-config.json
You may also need to make sure your service worker is registered. Nice presentation on the subject at: https://javascript-conference.com/wp-content/uploads/2017/12/Automatic_Progressive_Web_Apps_using_Angular_Service_Worker_Maxim_Salnikov.pdf

Related

What are the differences between a #nrwl/js library and a #nrwl/workspace library?

I have created both in a testing environment but am still having trouble to differentiate between the use cases of the two. They both have the same file structure, slightly different tsconfig.json file, #nrwl/js library is stricter by 2 extra props. Otherwise they seem to be the same. On the official site there is no info regarding the differences between the two.
Any help is appreciated.
#nrwl/js:library
Use to generate a generic typescript library.
npx nx g #nrwl/js:library --name myLibrary --directory common --buildable # creates libs/common/my-library
#nrwl/workspace:library
Use to generate a UI focused typescript library.
npx nx g #nrwl/workspace:library --name myLibrary --directory common --buildable # creates libs/common/my-library
Differences
#nrwl/workspace:library has a .babelrc file that is not present in #nrwl/js:library
#nrwl/workspace:library has a jest.config.ts that supports .tsx files while #nrwl/js:library only supports .ts files
The tsconfig files are different
How I found the differences
I created a library using each generator
npx nx g #nrwl/js:library --name library --directory common/nrwljs --buildable
npx nx g #nrwl/workspace:library --name library --directory common/nrwlworkspace --buildable
Then I compared the files of each
diff -rq libs/common/nrwljs/library libs/common/nrwlworkspace/
Only in libs/common/nrwlworkspace/library: .babelrc
Files libs/common/nrwljs/library/README.md and libs/common/nrwlworkspace/library/README.md differ
Files libs/common/nrwljs/library/jest.config.ts and libs/common/nrwlworkspace/library/jest.config.ts differ
Files libs/common/nrwljs/library/package.json and libs/common/nrwlworkspace/library/package.json differ
Files libs/common/nrwljs/library/project.json and libs/common/nrwlworkspace/library/project.json differ
Files libs/common/nrwljs/library/src/index.ts and libs/common/nrwlworkspace/library/src/index.ts differ
Only in libs/common/nrwljs/library/src/lib: common-nrwljs-library.spec.ts
Only in libs/common/nrwljs/library/src/lib: common-nrwljs-library.ts
Only in libs/common/nrwlworkspace/library/src/lib: common-nrwlworkspace-library.spec.ts
Only in libs/common/nrwlworkspace/library/src/lib: common-nrwlworkspace-library.ts
Files libs/common/nrwljs/library/tsconfig.json and libs/common/nrwlworkspace/library/tsconfig.json differ
Files libs/common/nrwljs/library/tsconfig.lib.json and libs/common/nrwlworkspace/library/tsconfig.lib.json differ
Files libs/common/nrwljs/library/tsconfig.spec.json and libs/common/nrwlworkspace/library/tsconfig.spec.json differ
It's about the options you can use for each generator. Here are the documentation of the generators:
https://nx.dev/packages/workspace/generators/library
https://nx.dev/packages/angular/generators/library
Angular generator has some specific options, eg to include routing or lazy behaviours.

Unable to run/debug robot tests in vscode - robocorp extensions installed

I have installed Robocorp Code as well as Robot Framework Language Server and have configured them. However, I am still having errors when trying to run the tests via the code lens options.
Repo - A webapi repo with a specific folder containing all tests. Lets call it regression.
RF - 4.1.3
Python - 3.8
This is what happens when I click on Run on the code lens for any of the tests -
`PS C:\git\xxxx\regression> C:; cd 'C:\git\xxxx\regression'; &
'C:\Users\xxxx\AppData\Local\Temp\rf-ls-run\run_env_00_smh5defr.bat'
'-u'
'c:\Users\xxxx.vscode\extensions\robocorp.robotframework-lsp-0.47.2\src\robotframework_debug_adapter\run_robot__main__.py'
'--port' '54331' '--no-debug' '--argumentfile'
'C:\git\xxxx\regression\args-local.txt' '--pythonpath'
'c:\git\xxxx\regression\common\lib' '--variable'
'EXECDIR:C:/git/xxxx/regression'
'--prerunmodifier=robotframework_debug_adapter.prerun_modifiers.FilteringTestsSuiteVisitor'
'c:\git\xxxx\regression\api\api_Test.robot'
[ ERROR ] Parsing'--pythonpath' failed: File or directory to execute does not exist.
However, the test starts if I remove the argumentfile parameter but it, of course, fails because its missing arguments from the file.
Do note that the folder specified in pythopath exists and has some python libraries needed for the tests.

pytest-appium: cannot start tests, got SKIPPED

Trying to run tests with pytest-appium plugin.
Trying to start tests as usual, without any additional cmdline arguments:
SKIPPED [1] projects/Python/3/appium-tests/venv/lib/python3.8/site-packages/pytest_appium/plugin.py:8: no variables file
When started tests with --variables=vars.json (also added corresponding file to the project):
SKIPPED [1] projects/Python/3/appium-tests/venv/lib/python3.8/site-packages/pytest_appium/plugin.py:12: no "caps" or "server" in variables
Was trying also with caps or server or altogether in vars.json, same result:
SKIPPED [1] projects/Python/3/appium-tests/venv/lib/python3.8/site-packages/pytest_appium/plugin.py:12: no "caps" or "server" in variables
What am I doing wrong?
Your problem seems to be that you are using the wrong pytest-appium.
In PyPi, pytest-appium points to this project, which is a very basic plugin probably created for testing purposes.
The plugin you reference seems not to be released on PyPi, so you have to clone and install it from the repositiory:
pip uninstall pytest-appium # get rid of the wrong one
git clone https://github.com/GlobalRadio/pytest-appium.git
cd pytest-appium
pip install .

How to build Conda env on Mac using Windows yml file?

I'm creating Conda create environment from yml I generated on Windows' Miniconda install. I need to create same environment on OS X. Following the advise found here on SO I used the --no-builds option.
Also, the names of some packages under section ResolvePackageNotFound are clearly (many if not all) specific to Windows:
- m2w64-gmp=6.1.0
- m2w64-gcc-libs-core=5.3.0
- m2w64-gcc-libs=5.3.0
- vc=14.1
- vs2015_runtime=15.5.2
- msys2-conda-epoch=20160418
- menuinst=1.4.14
- icc_rt=2019.0.0
- m2w64-libwinpthread-git=5.0.0.4634.697f757
- pywinpty=0.5.5
- wincertstore=0.2
- m2w64-gcc-libgfortran=5.3.0
- win_inet_pton=1.1.0
- winpty=0.4.3
I removed all of these from the yml file. Even then it's stalled at the following screen:
(base) MacBook-Air:Anaconda.d xtian$ conda env create -f 32b-qb-2019-10-05.yml
Collecting package metadata (repodata.json): done
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abor|
Examining openssl: 10%|█████████▍ | 29/279 [00:00<00:00, 3729.87it- ]
Comparing specs that have this dependency: 16%|██████████▉ | 16/101 [05:53<31:19, 22.11s/it]
Finding shortest conflict path for openssl[version='>=1.0.2p,<1.0.3a']: 38%|███████████████▊ | 6/16 [02:39<06:23, 38.32s/it]
This process is progressing at an astonishingly slow pace, and hasn't got past openssl ... 29/279. Should I wait and trust Conda can figure this all out?
Or,
Do I need another strategy--
I'm wondering if I can't remove the offending packages, each in turn, and create a series of yml files to install in order using, $ conda env update --prefix ./env --file environment.yml --prune, because whatever finally works here I know I'm going to need to use it on another machine so I can share the project env with a colleague.
Any other suggestions?
Short answer: Try deleting the packages that your system is getting stuck on from the .yml file. i.e., remove "openssl" from .yml file.
I have been running into the same issue trying to install a .yml file created in a Windows system to a Mac system. I basically followed the same procedure you did:
-Created yml file using the --no-builds option.
-Attempted to create environment on Mac system and had several windows specific packages left under ResolvePackageNotFound section (listed below)
m2w64-libwinpthread-git=5.0.0.4634.697f757
pyreadline=2.1
pywinpty=0.5.5
m2w64-gcc-libgfortran=5.3.0
vc=14
m2w64-gcc-libs-core=5.3.0
m2w64-gmp=6.1.0
wincertstore=0.2
icc_rt=2019.0.0
m2w64-gcc-libs=5.3.0
vs2015_runtime=14.15.26706
winpty=0.4.3
msys2-conda-epoch=20160418
-Deleted those from the yml file
-Attempted to create environment from updated yml file and received the following conflicts:
- Found conflicts! Looking for incompatible packages.
My system also got stuck trying to solve the "openssl" conflict along with a "_tflow_select". I ended up deleting those and was able to create my environment and run the code without too much trouble.

Error installing purescript-list

I'm new to Purescript and am following the tutorial for installation. Purescript itself is working and I can start the CLI using pulp psci, but installing purescript-list runs into trouble.
Having entered the command bower install purescript-lists --save, I get a long list of package names, but when it gets to purescript-eff and purescript-prelude I run into some version conflicts:
bower purescript-eff#^2.0.0 cached https://github.com/purescript/purescript-eff.git#2.0.0
bower purescript-eff#^2.0.0 validate 2.0.0 against https://github.com/purescript/purescript-eff.git#^2.0.0
Unable to find a suitable version for purescript-eff, please choose one by typing one of the numbers below:
1) purescript-eff#^1.0.0 which resolved to 1.0.0 and is required by purescript-console#1.0.0
2) purescript-eff#^2.0.0 which resolved to 2.0.0 and is required by purescript-st#2.0.0
Prefix the choice with ! to persist it to bower.json
? Answer
A similar message is shown for purescript-prelude. No matter which options I choose, both pulp build and pulp run fail with:
$ pulp build
* Building project in /Developer/purescript/training1
Error found:
in module PSCI.Support
at /Developer/purescript/training1/bower_components/purescript-psci-support/src/PSCI/Support.purs line 10, column 34 - line 10, column 53
Cannot import value unsafeInterleaveEff from module Control.Monad.Eff.Unsafe
It either does not exist or the module does not export it.
See https://github.com/purescript/purescript/wiki/Error-Code-UnknownImport for more information,
or to contribute content related to this error.
Compiling PSCI.Support
* ERROR: Subcommand terminated with exit code 1
What have I missed here?
Thanks
Chris W
If you are using psc version 0.10.* you should go with prelude, lists and eff v2*.
If you are using psc version 0.9.* you should go with prelude, lists and eff v1*.
If you are using psc 0.10.* you might want to update pulp to version 9.1.0
The problem occurs due to breaking changes between psc 0.9 and 0.10 and the relevant libraries. by writing bower install purescript-lists --save you are asking bower for the latest dependencies which conflict with the dependency versions specified in your bower.json.