Configure JSON in Arkit to visualize NPM modules in Package.json - node.js

I am using the following npm package named arkit in order to create architecture diagrams of node.js projects, but I am unable to visualize npm packages (dependencies folder) in my node.js application architecture as depicted in the examples of Arkit and Vue/Nuxt TodoMVC, I tried to follow the json configuration of each of their respective arkits but either they are non-existent like in Vue or vague like in Arkit itself.
I used the config given in arkit configuration example but I end up with all dependencies of main dependencies like this. I tried the following config
{ "$schema": "https://arkit.pro/schema.json",
"excludePatterns": ["test/**", "tests/**", "**/*.test.*", "**/*.spec.*"],
"components": [
{ "type": "Dependency",
"patterns": ["node_modules/**/*.js"] },
{ "type": "Component",
"patterns": ["**/*.js", "**/*.jsx"]
}
],
"output": [
{ "path": "arkit.svg",
"groups": [ { "first": true, "components": ["Component"] },
{
"type": "Dependencies",
"components": ["Dependency"]
}
]
}
]
}
but it crashed during architecture generation, I also emailed the owner of this npm package and one other person who successfully managed to do so, but they are busy to guide me in configuring JSON of arkit.
Can I use the for-of loop in the JSON config file in order to get only those node_modules which are included in package.json as I don't want to get additional sub-dependencies of the main npm packages in the architecture representation as depicted in the link shared above!
TL;DR
I want diagrams with dependencies like these but I am getting this
I tried, adding --depth=0 in the command line "npx arkit --config test.json --depth=0" but no luck

I think arkit expects output.path to be an array - but you are passing it a string. Try using the modified config:
{
"$schema": "https://arkit.pro/schema.json",
"excludePatterns": ["test/**", "tests/**", "**/*.test.*", "**/*.spec.*"],
"components": [{
"type": "Dependency",
"patterns": ["node_modules/*"]
},
{
"type": "Component",
"patterns": ["**/*.js", "**/*.jsx"]
}
],
"output": [{
"path": ["arkit.svg"],
"groups": [{
"first": true,
"components": ["Component"]
},
{
"type": "Dependencies",
"components": ["Dependency"]
}
]
}]
}

It's working on Ubuntu as if there are more reasons to hate Windows 10. I implemented the package.json config of the authors Vue application and viola it worked like a charm. 2 months of looking for answers and trying everything on Windows, Ubuntu did the trick

Related

Make Yarn don't hoist the dependencies of the specific package

In below project, I want all dependencies of TodoList will no be hosted to node_modules in root directory of monorepo.
Below settings is not enough to reach this effect:
{
"private": true,
"workspaces": {
"packages": [ "BusinessRules", "Server", "TodoList" ],
"nohoist": [
"TodoList/**"
]
}
}
"TodoList/**/**" is not enough too.
How to make all dependencies of TodoList will be inside TodoList/node_modules?
Found the solution here.
In this case, it's required to add below JSON in TodoList/package.json:
"workspaces": {
"nohoist": ["**"]
},

VSCode AWS Sam (node12.x image) TypeScript debugger not reaching breakpoints

Im trying to get vscode debugger to work with an application generated with AWS Sam, but with TypeScript.
So before I added TypeScript, the debugger worked fine, I could reach the breakpoints without issue.
When I added TypeScript, I had to change to folder structure, by adding a src and dist folder, so currently my file structure is like this:
According to AWS documentation (page 58): https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/aws-tookit-vscode-ug.pdf
I think it has to do with the pathMappings in the launch.json file, but I can't seem to figure out what would the correct path. This is my current launch.json file:
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "puppeteer-pdfMerger:HelloWorldFunction",
"invokeTarget": {
"target": "template",
"templatePath": "puppeteer-pdfMerger/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"runtime": "nodejs12.x",
"payload": {},
"environmentVariables": {},
"pathMappings": [{
"localRoot": "${workspaceFolder}/puppeteer-pdfMerger/hello-world/dist/HelloWorldFunction",
"remoteRoot": "/var/task/dist"
}]
}
}
}
I will note that when running this configuration the containerized Lambda runs fine, it's just the breakpoints are not working.
I managed to get the breakpoints to work in the end.
What ended up working for me was changing the Dockerfile to:
FROM public.ecr.aws/lambda/nodejs:12
COPY dist/*.js package.json ./
RUN npm install
# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambdaHandler"]
And having the launch.json config as follows:
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "puppeteer-pdfMerger:PdfGeneratorAndMergerFunction TemplateTarget",
"invokeTarget": {
"target": "template",
"templatePath": "puppeteer-pdfMerger/template.yaml",
"logicalId": "PdfGeneratorAndMergerFunction"
},
"lambda": {
"runtime": "nodejs12.x",
"payload": {},
"environmentVariables": {},
"pathMappings": [
{
"localRoot": "${workspaceRoot}/puppeteer-pdfMerger/hello-world/dist",
"remoteRoot": "/var/task"
}
]
}
}

Vue/Node error : Rule can only have one resource source

I am brand new to Vue and Node and everything was going well with a Vue3 project I was messing around with to learn. I wanted to use scss files so installed sass-loader via npm using:
npm install sass-loader sass webpack --save-dev
And since then the app is broken, now when I try to serve I get the following error:
Error: Rule can only have one resource source (provided resource and test + include + exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "C:\\pathtoapp\\node_modules\\cache-loader\\dist\\cjs.js",
"options": {
"cacheDirectory": "C:\\pathtoapp\\node_modules\\.cache\\babel-loader",
"cacheIdentifier": "43be597c"
},
"ident": "clonedRuleSet-38.use[0]"
},
{
"loader": "C:\\pathtoapp\\node_modules\\babel-loader\\lib\\index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
Error: Rule can only have one resource source (provided resource and test + include + exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "C:\\pathtoapp\\node_modules\\cache-loader\\dist\\cjs.js",
"options": {
"cacheDirectory": "C:\\pathtoapp\\node_modules\\.cache\\babel-loader",
"cacheIdentifier": "43be597c"
},
"ident": "clonedRuleSet-38.use[0]"
},
{
"loader": "C:\\pathtoapp\\node_modules\\babel-loader\\lib\\index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
I looked up this error and most believed this to be an issue with webpack but I have uninstalled and installed again. Installed an earlier version of webpack, tried changing package.json to point to an earlier version, tried anything I can currently find on SO and now I'm completely stumped.
Any assistance on this would be much appreciated as I'd rather learn and discover how to fix the problem should I encounter it again rather than simply start a new project. Let me know any code/files I should post in an edit where required.
I ran into the same issue and I was able to resolve it by:
rm -rf node_modules
rm package-lock.json
npm install --legacy-peer-deps
Source

SPFx: Problem with loading schema in manifest JSON

I'm having problem with loading $schema in SPFx within my new web part for SP. Web part is working on benchmark.aspx but my whole manifest is not being processed so I can't set preconfiguredEntries and it's big problem for me.
error is:
Problems loading reference 'https://developer.microsoft.com/json-schemas/spfx/client-side-manifest-base.schema.json': Request vscode/content failed unexpectedly without providing any details.(768)
Any idea on this issue please?
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "56dab116-67ba-453f-883d-b7a11690e965",
"alias": "ReadListWebPart",
"supportedHosts": ["SharePointWebPart"],
"componentType": "Webpart",
"version": "1.0",
"manifestVersion": "2",
"requiresCustomScript": false,
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70",
"group": { "default": "Other" },
"title": { "default": "read-list" },
"description": { "default": "popis web party" },
"officeFabricIconFontName": "Page",
"properties": {
"vedouci_velke_foto": true,
"asistenti_pod_vedoucim": false,
"nazev_web_party": "To jsme my"
}
}]
}
I checked the manifest.json, will be the same as yours, have the following waring:
Then tested to access "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json" in my local, no problem, still can be accessed.
After this, I tested to output the preconfigured properties in React SPFX Web Part like this:
Props.ts
WebPart.ts
.tsx
Still able to output properties:
In conclusion, you can just igore this issue, it's still able to read preconfiguredEntries.

SPFX Package always referring content or resources from localhost instead from CDN

Can someone please let me know from where I can change this configuration so that it should refer from the CDN path instead of localhost
Below is my package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "mega-menu-sp-fx-client-side-solution",
"id": "8f49d75c-5a49-4657-b81b-0290f239350f",
"version": "10.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"features": [
{
"title": "Application Extension - Deployment of custom action.",
"description": "Deploys a custom action with ClientSideComponentId association",
"id": "0d2345df-2a49-4ce9-ba2d-bee7ad3e7a02",
"version": "10.0.0.0",
"assets": {
"elementManifests": [
"elements.xml",
"clientsideinstance.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/mega-menu-sp-fx.sppkg"
}
}
Below is my write-manifest.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "https://Mytenant.sharepoint.com/sites/MyTechTheme/MenuFiles"
}
I tried to figure out whats the issue. For publishing instead of gulp package-solution --ship I had used gulp package-solution so unless and until we don't mention --ship it wont take the references for CDN
So for deploying the package in SPO we need to use gulp bundle --ship and gulp package-solution --ship
As per this thread, to load SPFx assets from a CDN or SharePoint library, set the value of "includeClientSideAssets" to false.
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
...
"includeClientSideAssets": false,
...
}
}

Resources