Locally building and pushing VuePress site to Github Pages - github

Having trouble figuring out how the workflow for using Github as a VuePress site source control and deploying it to Github Pages.
When I ran deploy.sh the first time, it gave me a Github certificate error around the init command and did not initialize a new repo (I already have a repo setup so not sure if the init command in deploy.sh is required. Subsequent runs of deploy.sh resulted in no error.
**Problem:**Unfortunately, when I visit my Github Pages site, its not using VuePress templates.
I feel like I have either:
- The folder structure wrong
- The base set incorrectly in config.js
- The relative folders incorrect in deploy.sh
Can someone put eyes on this and give some feedback? Thank you.
For your reference
Local machine's folder structure:
user#system:~/powerDocs$ tree
.
├── deploy.sh
├── docs
│   └── README.md
├── node_modules
│   └── yarn
│   ├── bin
│   │   ├── yarn
│   │   ├── yarn.cmd
│   │   ├── yarn.js
│   │   ├── yarnpkg
│   │   └── yarnpkg.cmd
│   ├── lib
│   │   ├── cli.js
│   │   └── v8-compile-cache.js
│   ├── LICENSE
│   ├── package.json
│   └── README.md
├── package.json
├── package-lock.json
└── README.md
5 directories, 15 files
Content of deploy.sh:
#!/usr/bin/env sh
# abort on errors
set -e
# build
vuepress build
# navigate into the build output directory
cd docs/.vuepress/dist
# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME
git init
git add -A
git commit -m 'deploy'
# if you are deploying to https://<USERNAME>.github.io
# git push -f git#github.com:SeaDude/SeaDude.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f git#github.com:SeaDude/powerDocs.git master:gh-pages
cd -
I made deploy.sh executable with chmod +x deploy.sh. Running ./deploy.sh gives me the following output:
user#system:~/powerDocs$ ./deploy.sh
WAIT Extracting site metadata...
[12:05:53 PM] Compiling Client
[12:05:53 PM] Compiling Server
(node:15590) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
[12:05:57 PM] Compiled Server in 3s
[12:05:59 PM] Compiled Client in 6s
WAIT Rendering static HTML...
DONE Success! Generated static files in .vuepress/dist.
Reinitialized existing Git repository in /home/powerDocs/docs/.vuepress/dist/.git/
On branch master
nothing to commit, working directory clean
Here is the contents of config.js:
module.exports = {
title: "PowerDocs",
description: "Where functions go to frolic.",
base: "/powerDocs/",
themeConfig: {
nav: [
{ text: "Home", link: "/" }
],
sidebar: [
'/'
]
}
};

Have you checked your dist folder to see what is actually being output? The error makes it seem like there are no files present to commit after the build.
I have the almost identical setup locally and haven't run into this problem with it, the only difference being the command I run to build is yarn docs:build

Related

Yocto Error : Could not inherit file classes/qt6-cmake.bbclass

I'm currently trying to 'boot 2 qt'
I add layers, at "bblayers.conf"
like this.
/yocto/kirkstone/meta-boot2qt/meta-boot2qt \
and also set machine at "local.conf"
when I try to bitbake, the error occurs like this
Input : bitbake b2qt-embedded-qt6-image
Output: ERROR: ParseError at /home/seame-fablab/yocto/kirkstone/meta-boot2qt/meta-boot2qt/recipes-qt/boot2qt-addons/qdb_git.bb:36: Could not inherit file classes/qt6-cmake.bbclass
ERROR: Parsing halted due to errors, see error messages above
how to solve the errors
I believe its likely you are simply missing the layer where qt6-cmake.bbclass belongs to.
Its hard to say if you missed cloning it, or just adding it to your bblayers.conf since you didnt really specify how you actually cloned the repos, but the README for meta-boot2qt suggests you use repo for such task, which should've taken care of that for you.
For example, using
mkdir ~/mybuilddir
cd ~/mybuilddir/
repo init -u git://code.qt.io/yocto/boot2qt-manifest -m 6.5.xml
repo sync
would get you a structure like this:
$ tree -L 2
.
├── setup-environment.sh -> sources/meta-boot2qt/scripts/setup-environment.sh
└── sources
├── meta-boot2qt
├── meta-freescale
├── meta-freescale-3rdparty
├── meta-intel
├── meta-mingw
├── meta-openembedded
├── meta-qt6
├── meta-raspberrypi
├── meta-tegra
├── meta-toradex-bsp-common
├── meta-toradex-nxp
├── poky
└── templates -> meta-boot2qt/meta-boot2qt-distro/conf/templates/default
And the class you are missing is located at:
./sources/meta-qt6/classes/qt6-cmake.bbclass
Now, if you for some reason dont want to use repo and would like to manually clone the required layers, you are also welcome to do that, you just need to clone meta-qt6:
git clone https://code.qt.io/cgit/yocto/meta-qt6.git/
and add it to your bblayers.conf
bitbake-layers add-layer <path-to-meta-qt6-layer-you-just-cloned>

Pytest set default path/directory/fodler as project directory (solve FileNotFoundError)

I have the next tree:
root_project/
├── app
│   ├── default_photo_profile.jpg
│   ├── config.py
│   ├── __main__.py # My app are python package, I'm runnig it via "python -m"
│   └── ...
├── tests
│   ├── test_unit.py # import config.py inside
│   ├── functional # import config.py inside
│   ├── pytest.ini
│   └── ...
...
Currently default_photo_profile causing error because tests doesn't have this file.
Reading file in config.py:
DEFAULT_PHOTO_FILE_PATH = Path('default_photo.jpg')
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
How I can solve this?
I tried:
Patch access to default_photo.jpg with fixture - not helped, error during import stage, not executiion.
set flag to pytest comamnd line: --rootdir app - not helped (don't know why).
try/except for reading the file in app.config.py - may help but it's not my intention, I really want raise error if file not found
Put default_photo.jpg inside EVERY test directory - will help bit dirty.
Patch os.path like suggested in https://stackoverflow.com/a/43003192/11277611 - dirty
Include tests into package (move __main__.py into root_project - not sure that it's a good idea (have not enough experience to decide).
Set absolut path to default_photo.jpg - will fail on the production server.
Probably adoptable solutions (What I want):
Set root dir to root_project.app somehow inside pytest.ini to immitate regular execution.
Set root dir to root_project.tests somehow to place file in root of tests and access from any of tests folder.
Try to use following code in config.py:
DEFAULT_PHOTO_FILE_PATH = Path(__file__).parent / 'default_photo.jpg'
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
Is it what you are trying to achieve?

How to access templates part of a package from a script within a package

I have trouble creating a package with setuptools. I have a repository which I'm cleaning up to make it a package. The directory structure looks something like this
my-proj
├── setup.py
├── MANIFEST.in
├── MakeFile
├── README.rst
├── setup.py
└── myproj
├── __init__.py
├── my_code.py
├── templates
│ ├── template1.yaml
│ ├── template2.yaml
Initial version of "my_code.py" had code snippet which would directly reference the files withing templates folder to do some processing. If I package this using setup tools, I provide the following information in these files:
MANIFEST.in:
include README.rst
include requirements.txt
include LICENSE.txt
recursive-include myproj/templates *
setup.py:
setup(
name='myproj',
package_dir={'testbed_init': 'testbed_init'},
package_data={'templates': ['templates/*'], 'configs': ['configs/*']},
include_package_data=True,
)
My question is as follows. In "my_Code.py" I used to reference templates directly without any problem as I would run script from the myproj folder. If I package this, how can I make sure, I include the templates as part of package and when script runs, I need to open the templates relative to where the package is installed.
Code snippet from my_code.py:
if _type == "a":
temp_file = f"templates/template1.yaml"
else:
temp_file = f"templates/template2.yaml"
build_config(deploy_esx_file, output_file, data)
Code snippet of what happens in build_config:
def build_config(template_file, output_file, inputs):
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
template = templateEnv.get_template(template_file)
outputText = template.render(inputs)
with open(output_file, 'w') as h:
h.write(outputText)

Links to json files

my directory structure is
├── xxx
│   ├── 01.md
| └── 02.md
├── auth
│   ├── j1.json
│   ├── j2.json
│   └── j3.json
└── default.template.html
And I link jsons from markdowns like Auth. It makes sense as we use there files as test scenarios and in json files we have credentials and roles. But if I try to generate html it fails on unresolved internal reference: ../auth/aspect_admin.json. I tried to exclude the link checking but without any help. The best would be to leave it as a link in md file but somehow follow the link and include the json as code block in generated html. Is it possible?
It was a bug and will be fixed in next version https://github.com/planet42/Laika/issues/148

Error when attempting to install Karma

I am trying to install Karma using the following command:
C:\Program Files\nodejs>npm install karma
However, I receive the following error when I attempt to install Karma on my Windows 8.1 machine:
npm WARN optional dep failed, continuing fsevents#0.2.0
\
> ws#0.4.31 install C:\Program Files\nodejs\node_modules\karma\node_modules\sock
et.io\node_modules\socket.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
|
C:\Program Files\nodejs\node_modules\karma\node_modules\socket.io\node_modules\s
ocket.io-client\node_modules\ws>node "C:\Program Files\nodejs\node_modules\npm\b
in\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
karma#0.12.17 node_modules\karma
├── di#0.0.1
├── graceful-fs#2.0.3
├── rimraf#2.2.8
├── colors#0.6.2
├── mime#1.2.11
├── q#0.9.7
├── chokidar#0.8.2 (recursive-readdir#0.0.2)
├── minimatch#0.2.14 (sigmund#1.0.0, lru-cache#2.5.0)
├── optimist#0.6.1 (wordwrap#0.0.2, minimist#0.0.10)
├── glob#3.2.11 (inherits#2.0.1, minimatch#0.3.0)
├── source-map#0.1.37 (amdefine#0.1.0)
├── lodash#2.4.1
├── log4js#0.6.15 (semver#1.1.4, async#0.1.15, readable-stream#1.0.27-1)
├── useragent#2.0.9 (lru-cache#2.2.4)
├── http-proxy#0.10.4 (pkginfo#0.3.0, utile#0.2.1)
├── connect#2.12.0 (uid2#0.0.3, methods#0.1.0, cookie-signature#1.0.1, debug#0.8
.1, pause#0.0.1, fresh#0.2.0, qs#0.6.6, bytes#0.2.1, buffer-crc32#0.2.1, raw-bod
y#1.1.2, batch#0.5.0, cookie#0.1.0, negotiator#0.3.0, send#0.1.4, multiparty#2.2
.0)
└── socket.io#0.9.17 (base64id#0.1.0, policyfile#0.0.4, redis#0.7.3, socket.io-c
lient#0.9.16)
I don't think there are any errors.
Just need to install karma-cli
npm install -g karma-cli
Then karma should work.
I had the same problem. In my case the solution to the problem was to use the command in the right folder. I was one folder in hierarchy below where I should have been.