@somosme/weblowutils 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of @somosme/weblowutils might be problematic. Click here for more details.

package/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # Finsweet Developer Starter
2
+
3
+ A starter template for both Client & Power projects.
4
+
5
+ Before starting to work with this template, please take some time to read through the documentation.
6
+
7
+ ## Reference
8
+
9
+ - [Included tools](#included-tools)
10
+ - [Requirements](#requirements)
11
+ - [Getting started](#getting-started)
12
+ - [Installing](#installing)
13
+ - [Building](#building)
14
+ - [Serving files on development mode](#serving-files-on-development-mode)
15
+ - [Building multiple files](#building-multiple-files)
16
+ - [Setting up a path alias](#setting-up-a-path-alias)
17
+ - [Contributing guide](#contributing-guide)
18
+ - [Pre-defined scripts](#pre-defined-scripts)
19
+ - [CI/CD](#cicd)
20
+ - [Continuous Integration](#continuous-integration)
21
+ - [Continuous Deployment](#continuous-deployment)
22
+ - [How to automatically deploy updates to npm](#how-to-automatically-deploy-updates-to-npm)
23
+
24
+ ## Included tools
25
+
26
+ This template contains some preconfigured development tools:
27
+
28
+ - [Typescript](https://www.typescriptlang.org/): A superset of Javascript that adds an additional layer of Typings, bringing more security and efficiency to the written code.
29
+ - [Prettier](https://prettier.io/): Code formatting that assures consistency across all Finsweet's projects.
30
+ - [ESLint](https://eslint.org/): Code linting that enforces industries' best practices. It uses [our own custom configuration](https://github.com/finsweet/eslint-config) to maintain consistency across all Finsweet's projects.
31
+ - [Playwright](https://playwright.dev/): Fast and reliable end-to-end testing.
32
+ - [esbuild](https://esbuild.github.io/): Javascript bundler that compiles, bundles and minifies the original Typescript files.
33
+ - [Changesets](https://github.com/changesets/changesets): A way to manage your versioning and changelogs.
34
+ - [Finsweet's TypeScript Utils](https://github.com/finsweet/ts-utils): Some utilities to help you in your Webflow development.
35
+
36
+ ## Requirements
37
+
38
+ This template requires the use of [pnpm](https://pnpm.js.org/en/). You can [install pnpm](https://pnpm.io/installation) with:
39
+
40
+ ```bash
41
+ npm i -g pnpm
42
+ ```
43
+
44
+ To enable automatic deployments to npm, please read the [Continuous Deployment](#continuous-deployment) section.
45
+
46
+ ## Getting started
47
+
48
+ The quickest way to start developing a new project is by [creating a new repository from this template](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template#creating-a-repository-from-a-template).
49
+
50
+ Once the new repository has been created, update the `package.json` file with the correct information, specially the name of the package which has to be unique.
51
+
52
+ ### Installing
53
+
54
+ After creating the new repository, open it in your terminal and install the packages by running:
55
+
56
+ ```bash
57
+ pnpm install
58
+ ```
59
+
60
+ If this is the first time using Playwright and you want to use it in this project, you'll also have to install the browsers by running:
61
+
62
+ ```bash
63
+ pnpm playwright install
64
+ ```
65
+
66
+ You can read more about the use of Playwright in the [Testing](#testing) section.
67
+
68
+ It is also recommended that you install the following extensions in your VSCode editor:
69
+
70
+ - [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
71
+ - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
72
+
73
+ ### Building
74
+
75
+ To build the files, you have two defined scripts:
76
+
77
+ - `pnpm dev`: Builds and creates a local server that serves all files (check [Serving files on development mode](#serving-files-on-development-mode) for more info).
78
+ - `pnpm build`: Builds to the production directory (`dist`).
79
+
80
+ ### Serving files on development mode
81
+
82
+ When you run `pnpm dev`, two things happen:
83
+
84
+ - esbuild is set to `watch` mode. Every time that you save your files, the project will be rebuilt.
85
+ - A local server is created under `http://localhost:3000` that serves all your project files. You can import them in your Webflow projects like:
86
+
87
+ ```html
88
+ <script defer src="http://localhost:3000/{FILE_PATH}.js"></script>
89
+ ```
90
+
91
+ ### Building multiple files
92
+
93
+ If you need to build multiple files into different outputs, you can do it by updating the build settings.
94
+
95
+ In `bind/build.js`, update the `entryPoints` with any files you'd like to build:
96
+
97
+ ```javascript
98
+ const entryPoints = [
99
+ 'src/home/index.ts',
100
+ 'src/contact/whatever.ts',
101
+ 'src/hooyah.ts',
102
+ 'src/home/other.ts',
103
+ ];
104
+ ```
105
+
106
+ This will tell `esbuild` to build all those files and output them in the `dist` folder for production and in `http://localhost:3000` for development.
107
+
108
+ ### Setting up a path alias
109
+
110
+ Path aliases are very helpful to avoid code like:
111
+
112
+ ```typescript
113
+ import example from '../../../../utils/example';
114
+ ```
115
+
116
+ Instead, we can create path aliases that map to a specific folder, so the code becomes cleaner like:
117
+
118
+ ```typescript
119
+ import example from '$utils/example';
120
+ ```
121
+
122
+ You can set up path aliases using the `paths` setting in `tsconfig.json`. This template has an already predefined path as an example:
123
+
124
+ ```json
125
+ {
126
+ "paths": {
127
+ "$utils/*": ["src/utils/*"]
128
+ }
129
+ }
130
+ ```
131
+
132
+ To avoid any surprises, take some time to familiarize yourself with the [tsconfig](/tsconfig.json) enabled flags.
133
+
134
+ ## Testing
135
+
136
+ As previously mentioned, this library has [Playwright](https://playwright.dev/) included as an automated testing tool.
137
+
138
+ All tests are located under the `/tests` folder. This template includes a test spec example that will help you catch up with Playwright.
139
+
140
+ After [installing the dependencies](#installing), you can try it out by running `pnpm test`.
141
+ Make sure you replace it with your own tests! Writing proper tests will help improve the maintainability and scalability of your project in the long term.
142
+
143
+ By default, Playwright will also run `pnpm dev` in the background while the tests are running, so [your files served](#serving-files-on-development-mode) under `localhost:3000` will run as usual.
144
+ You can disable this behavior in the `playwright.config.ts` file.
145
+
146
+ If you project doesn't require any testing, you should disable the Tests job in the [CI workflow](#continuous-integration) by commenting it out in the `.github/workflows/ci.yml` file.
147
+ This will prevent the tests from running when you open a Pull Request.
148
+
149
+ ## Contributing guide
150
+
151
+ In general, your development workflow should look like this:
152
+
153
+ 1. Create a new branch where to develop a new feature or bug fix.
154
+ 2. Once you've finished the implementation, [create a Changeset](#continuous-deployment) (or multiple) explaining the changes that you've made in the codebase.
155
+ 3. Open a Pull Request and wait until the [CI workflows](#continuous-integration) finish. If something fails, please try to fix it before merging the PR.
156
+ If you don't want to wait for the CI workflows to run on GitHub to know if something fails, it will be always faster to run them in your machine before opening a PR.
157
+ 4. Merge the Pull Request. The Changesets bot will automatically open a new PR with updates to the `CHANGELOG.md`, you should also merge that one. If you have [automatic npm deployments](#how-to-automatically-deploy-updates-to-npm) enabled, Changesets will also publish this new version on npm.
158
+
159
+ If you need to work on several features before publishing a new version on npm, it is a good practise to create a `development` branch where to merge all the PR's before pushing your code to master.
160
+
161
+ ## Pre-defined scripts
162
+
163
+ This template contains a set of predefined scripts in the `package.json` file:
164
+
165
+ - `pnpm dev`: Builds and creates a local server that serves all files (check [Serving files on development mode](#serving-files-on-development-mode) for more info).
166
+ - `pnpm build`: Builds to the production directory (`dist`).
167
+ - `pnpm lint`: Scans the codebase with ESLint and Prettier to see if there are any errors.
168
+ - `pnpm check`: Checks for TypeScript errors in the codebase.
169
+ - `pnpm format`: Formats all the files in the codebase using Prettier. You probably won't need this script if you have automatic [formatting on save](https://www.digitalocean.com/community/tutorials/code-formatting-with-prettier-in-visual-studio-code#automatically-format-on-save) active in your editor.
170
+ - `pnpm test`: Will run all the tests that are located in the `/tests` folder.
171
+ - `pnpm test:headed`: Will run all the tests that are located in the `/tests` folder visually in headed browsers.
172
+ - `pnpm release`: This command is defined for [Changesets](https://github.com/changesets/changesets). You don't have to interact with it.
173
+ - `pnpm run update`: Scans the dependencies of the project and provides an interactive UI to select the ones that you want to update.
174
+
175
+ ## CI/CD
176
+
177
+ This template contains a set of helpers with proper CI/CD workflows.
178
+
179
+ ### Continuous Integration
180
+
181
+ When you open a Pull Request, a Continuous Integration workflow will run to:
182
+
183
+ - Lint & check your code. It uses the `pnpm lint` and `pnpm check` commands under the hood.
184
+ - Run the automated tests. It uses the `pnpm test` command under the hood.
185
+
186
+ If any of these jobs fail, you will get a warning in your Pull Request and should try to fix your code accordingly.
187
+
188
+ **Note:** If your project doesn't contain any defined tests in the `/tests` folder, you can skip the Tests workflow job by commenting it out in the `.github/workflows/ci.yml` file. This will significantly improve the workflow running times.
189
+
190
+ ### Continuous Deployment
191
+
192
+ [Changesets](https://github.com/changesets/changesets) allows us to generate automatic changelog updates when merging a Pull Request to the `master` branch.
193
+
194
+ To generate a new changelog, run:
195
+
196
+ ```bash
197
+ pnpm changeset
198
+ ```
199
+
200
+ You'll be prompted with a few questions to complete the changelog.
201
+
202
+ Once the Pull Request is merged into `master`, a new Pull Request will automatically be opened by a changesets bot that bumps the package version and updates the `CHANGELOG.md` file.
203
+ You'll have to manually merge this new PR to complete the workflow.
204
+
205
+ If an `NPM_TOKEN` secret is included in the repository secrets, Changesets will automatically deploy the new package version to npm.
206
+ Keep reading for more info about this.
207
+
208
+ #### How to automatically deploy updates to npm
209
+
210
+ As mentioned before, Changesets will automatically deploy the new package version to npm if an `NPM_TOKEN` secret is provided.
211
+
212
+ This npm token should be:
213
+
214
+ - From Finsweet's npm organization if this repository is meant for internal/product development.
215
+ - From a client's npm organization if this repository is meant for client development. In this case, you should ask the client to [create an npm account](https://www.npmjs.com/signup) and provide you the credentials (or the npm token, if they know how to get it).
216
+
217
+ Once you're logged into the npm account, you can get an access token by following [this guide](https://docs.npmjs.com/creating-and-viewing-access-tokens).
218
+
219
+ The access token must be then placed in a [repository secret](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-codespaces#adding-secrets-for-a-repository) named `NPM_TOKEN`.
@@ -0,0 +1 @@
1
+ "use strict";(()=>{function t(){let a=document.querySelector("#calendly-form"),o=window.location.search,l=new URLSearchParams(o);if(a)for(let e of l.keys())e==="name"?a.dataset.url+=`&name=${l.get(e)}`:e==="email"?a.dataset.url+=`&email=${l.get(e)}`:e==="address"&&(a.dataset.url+=`&a2=${l.get(e)}`)}window.Webflow||(window.Webflow=[]);window.Webflow.push(()=>{t()});})();
@@ -0,0 +1 @@
1
+ "use strict";(()=>{var a=document.querySelector("#step-1"),i=document.querySelector("#step-2"),r=document.querySelector("#step-3");d(a);d(i);d(r);b();function d(t){let s=t.querySelectorAll("a"),o=m(t);s.forEach(n=>{n.addEventListener("click",function(){o=m(t),this.classList.contains("selected")||(this.classList.add("selected"),o.classList.remove("selected")),o=m(t),t.id==="step-1"&&o.id==="somos-membership"?M():t.id==="step-1"&&o.id==="somos-app"&&y(),b()})})}function m(t){return t.querySelector(".selected")}function y(){i.style.display="none",r.querySelector("#step-3-step").textContent="2) "}function M(){i.style.display="block",r.querySelector("#step-3-step").textContent="3) "}function b(){let t=a.querySelector(".selected"),s=i.querySelector(".selected"),o=r.querySelector(".selected"),n=document.querySelector("#membership-type"),p=t.id,l=Number(o.dataset.time),c=s.dataset.analisisType,e;switch(T()){case"somos-membership-general-basic-6-meses-MXN-Monthly":e="515";break;case"somos-membership-general-basic-3-meses-MXN-Monthly":e="879";break;case"somos-membership-energia-basic-3-meses-MXN-Monthly":e="514";break;case"somos-membership-energia-basic-6-meses-MXN-Monthly":e="333";break;case"somos-membership-cardio-basic-3-meses-MXN-Monthly":e="455";break;case"somos-membership-cardio-basic-6-meses-MXN-Monthly":e="303";break;case"somos-membership-diabe-basic-3-meses-MXN-Monthly":e="468";break;case"somos-membership-diabe-basic-6-meses-MXN-Monthly":e="310";break;case"somos-app-3-meses-MXN-Monthly":e="280";break;case"somos-app-6-meses-MXN-Monthly":e="216";break;default:console.log("no plan found");break}let u=document.querySelector("#total");p==="somos-membership"?(n.textContent=`${l} meses - con an\xE1lisis ${c}`,e="$"+e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),u.textContent=String(e)):(n.textContent=`${l} meses - sin an\xE1lisis`,e="$"+e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),u.textContent=String(e))}function T(){let s=a.querySelector(".selected").id,n=i.querySelector(".selected").id,l=r.querySelector(".selected").id,c,e;s==="somos-app"?(c=s+"-"+l+"-MXN-Monthly",e=`https://somos-smart-wellness.chargebee.com/hosted_pages/checkout?subscription_items[item_price_id][0]=${c}&subscription_items[quantity][0]=1`):(c=s+"-"+n+"-"+l+"-MXN-Monthly",e=`https://somos-smart-wellness.chargebee.com/hosted_pages/checkout?subscription_items[item_price_id][0]=${c}&subscription_items[quantity][0]=1`);let h=document.querySelector("#checkout-btn");return h.href=e,c}})();
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(()=>{function o(){let e=window.location.search,t=new URLSearchParams(e).get("email");return t||!1}async function n(e){let t=await(await fetch(`https://eo5582hx14eo9sn.m.pipedream.net/?email=${e}`)).json();function r(){let m=document.getElementById("leadName");m.textContent=t.name}r()}window.Webflow||(window.Webflow=[]);window.Webflow.push(()=>{let e=o();e&&n(e)});})();
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@somosme/weblowutils",
3
+ "version": "2.0.0",
4
+ "description": "SOMOS.ME Developer",
5
+ "homepage": "https://github.com/Somos-Smart-Wellness/webflow_somos#readme",
6
+ "license": "ISC",
7
+ "keywords": [],
8
+ "author": {
9
+ "name": "SOMOS Webfow",
10
+ "url": "https://www.somos.me/"
11
+ },
12
+ "publishConfig":{
13
+ "access": "public"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Somos-Smart-Wellness/webflow_somos"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/Somos-Smart-Wellness/webflow_somos/issues"
21
+ },
22
+ "type": "module",
23
+ "main": "src/index.ts",
24
+ "module": "src/index.ts",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "dev": "cross-env NODE_ENV=development node ./bin/build.js",
30
+ "build": "cross-env NODE_ENV=production node ./bin/build.js",
31
+ "lint": "eslint --ignore-path .gitignore ./src && prettier --check ./src",
32
+ "check": "tsc --noEmit",
33
+ "format": "prettier --write ./src",
34
+ "test": "pnpm playwright test",
35
+ "test:headed": "pnpm playwright test --headed",
36
+ "release": "changeset publish",
37
+ "update": "pnpm update -i -L"
38
+ },
39
+ "devDependencies": {
40
+ "@changesets/changelog-git": "^0.1.12",
41
+ "@changesets/cli": "^2.24.1",
42
+ "@finsweet/eslint-config": "^1.1.5",
43
+ "@finsweet/tsconfig": "^1.1.0",
44
+ "@playwright/test": "^1.24.2",
45
+ "@trivago/prettier-plugin-sort-imports": "^3.3.0",
46
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
47
+ "@typescript-eslint/parser": "^5.32.0",
48
+ "cross-env": "^7.0.3",
49
+ "esbuild": "^0.14.53",
50
+ "eslint": "^8.21.0",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-plugin-prettier": "^4.2.1",
53
+ "prettier": "^2.7.1",
54
+ "typescript": "^4.7.4"
55
+ },
56
+ "dependencies": {
57
+ "@finsweet/ts-utils": "^0.33.1"
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { getEmailFromUrl } from '$utils/getEmailFromUrl';
2
+ import { getNameFromTypeform } from '$utils/getNameFromTypeform';
3
+
4
+ window.Webflow ||= [];
5
+ window.Webflow.push(() => {
6
+ const email = getEmailFromUrl();
7
+
8
+ if (email) {
9
+ getNameFromTypeform(email);
10
+ }
11
+ });