Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Publish packages on the NPM registry #698

Merged
merged 33 commits into from
Jun 13, 2024

Conversation

amovar18
Copy link
Collaborator

@amovar18 amovar18 commented May 30, 2024

Description

This PR aims to publish the following packages on NPM registry:

  • analysis-utils
  • cli-dashboard
  • cli
  • common
  • design-system
  • i18n
  • library-detection

Relevant Technical Choices

  • Script for publishing packages locally and in the npm registry has been added. Also, the script for unpublishing the locally published package has been added.
  • The CLI package generates a JSON file and an HTML file. The HTML file can be viewed without running a dev server.
  • Once the CLI is done with site/sitemap analysis the index.tml file from cli-dashboard is read and then we add the JSON data under a script tag in the window object associated with PSAT_DATA.
  • Then this index.html file along with the cliDashboard.js file is copied to the out directory.
  • To make report generation work we add the script for report generation in the index.html that is read from the cli-dashboard file as well in a base64 format under the window object with a variable PSAT_REPORT.
  • Once the user clicks on the download report the window.PSAT_REPORT is read then it is base64 decoded which gives the report javascript, now a new index.html file is generated with the report javascript under the script tag which is the static HTML format of the cookie landing page.
  • New commands have been added that utilise the workspace feature of NPM in the following format: packagename:build

Testing Instructions

This PR has to be tested in 2 different ways:

  1. When PSAT is installed in a project:
  • Clone this branch and run npm i.
  • (Optional) the registry start command required coreutils which is not available on OSX so its better to install coreutils using brew install coreutils.
  • In the terminal run npm run local-registry:start.
  • In the terminal run npm run publish:all:local this will build all the packages that need to be published.
  • Check the cli using npm run cli command and check the extension if it works properly.
  • Then go to http://localhost:4873 you will see all the packages that have been published.
  • Now create a new directory outside ps-analysis-tool.
  • In the new directory run npm init.
  • Then run npm install @ps-analysis-tool/cli --registry=http://localhost:4873.
  • Now run the cli using the npx psat command.
  • Verify that the cli now runs properly.
  • Now in terminal where you ran npm run local-registry:start run npm run local-registry:stop.
  1. When PSAT is installed globally:
  • Install the psat globally using npm i @ps-analysis-tool/cli @ps-analysis-tool/cli-dashboard -g --registry=http://localhost:4873.
  • Run the cli using the psat command.

Screenshot/Screencast


Checklist

  • I have thoroughly tested this code to the best of my abilities.
  • I have reviewed the code myself before requesting a review.
  • [ ] This code is covered by unit tests to verify that it works as intended. NA
  • The QA of this PR is done by a member of the QA team (to be checked by QA).

Fixes #589

@amovar18 amovar18 self-assigned this May 30, 2024
@mohdsayed mohdsayed changed the title Feature: Publishing packages on NPM registry Feature: Publish packages on the NPM registry May 31, 2024
@mohdsayed mohdsayed added this to the v1.0.0 milestone May 31, 2024
@amovar18 amovar18 marked this pull request as ready for review June 11, 2024 18:43
@amovar18 amovar18 requested review from mohdsayed, mayan-000 and ayushnirwal and removed request for mohdsayed and mayan-000 June 11, 2024 18:43
@ayushnirwal
Copy link
Contributor

ayushnirwal commented Jun 12, 2024

Please mention a test instruction stating to install the command globally and test that
npm I psat -g
psat ...

This PR may also fix the spawn error issue mentioned in issue #677 's in newer versions of Node since we are not spawning a new server to serve CLI dashboard. Let's test that too.

@mohdsayed
Copy link
Collaborator

@amovar18 Please resolve conflicts

@mohdsayed mohdsayed merged commit 426026d into develop Jun 13, 2024
4 checks passed
@mohdsayed mohdsayed deleted the feat/npm-package-publishing branch June 13, 2024 03:47
@mohdsayed mohdsayed mentioned this pull request Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants