1 | const path = require('path');
|
2 | const particlesJsFoundError = "particles.js-found";
|
3 | const reactParticlesJsFoundError = "react-particles-js-found";
|
4 |
|
5 | try {
|
6 | console.log("Thank you for installing tsParticles.");
|
7 | console.log("Remember to checkout the official website https://particles.js.org to explore some samples.");
|
8 | console.log("You can find more samples on CodePen too: https://codepen.io/collection/DPOage");
|
9 | console.log("If you need documentation you can find it here: https://particles.js.org");
|
10 | console.log("Remember to leave a star on the tsParticles repository if you like the project and want to support it: https://github.com/matteobruni/tsparticles");
|
11 |
|
12 | const pkgSettings = require(path.join(process.env.INIT_CWD, "package.json"));
|
13 |
|
14 | if (!pkgSettings) {
|
15 | return;
|
16 | }
|
17 |
|
18 | const dependencies = pkgSettings.dependencies;
|
19 |
|
20 | if (!dependencies) {
|
21 | return;
|
22 | }
|
23 |
|
24 | if (dependencies["particles.js"]) {
|
25 | console.error("\x1b[31m%s\x1b[0m", "The package particles.js can't be installed with tsparticles, since it can lead to unexpected behaviors, please uninstall particles.js and remove it from the package.json file.");
|
26 |
|
27 | throw new Error(reactParticlesJsFoundError);
|
28 | }
|
29 |
|
30 | if (dependencies["react-particles-js"]) {
|
31 | console.error("\x1b[31m%s\x1b[0m", "The package react-particles-js has been deprecated and is not supported anymore.");
|
32 | console.error("\x1b[31m%s\x1b[0m", "Please consider switching to react-particles package.")
|
33 | console.error("\x1b[31m%s\x1b[0m", "This error will be fixed once react-particles-js is removed from the package.json file.");
|
34 |
|
35 | throw new Error(reactParticlesJsFoundError);
|
36 | }
|
37 |
|
38 | if (dependencies["react"] || dependencies["next"]) {
|
39 | if (!dependencies["react-particles"]) {
|
40 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found React installed. Please download react-particles to use tsParticles with a component ready to use and easier to configure.");
|
41 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/react/README.md");
|
42 | }
|
43 | }
|
44 |
|
45 | if (dependencies["@angular/core"]) {
|
46 | if (!dependencies["ng-particles"]) {
|
47 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Angular installed. Please download ng-particles to use tsParticles with a component ready to use and easier to configure.");
|
48 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/angular/README.md");
|
49 | }
|
50 | }
|
51 |
|
52 | if (dependencies["vue"] || dependencies["nuxt"]) {
|
53 | const vueVersion = dependencies["vue"];
|
54 | const nuxtVersion = dependencies["nuxt"];
|
55 |
|
56 | const vueMajor = (vueVersion || nuxtVersion).split(".")[0];
|
57 |
|
58 | if (vueMajor > 2) {
|
59 | if (!dependencies["vue3-particles"]) {
|
60 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Vue 3.x installed. Please Download vue3-particles to use tsParticles with a component ready to use and easier to configure.");
|
61 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/vue3/README.md");
|
62 | }
|
63 | } else {
|
64 | if (!dependencies["vue2-particles"]) {
|
65 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Vue 2.x installed. Please Download vue2-particles to use tsParticles with a component ready to use and easier to configure.");
|
66 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/vue/README.md");
|
67 | }
|
68 | }
|
69 |
|
70 | }
|
71 |
|
72 | if (dependencies["svelte"]) {
|
73 | if (!dependencies["svelte-particles"]) {
|
74 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Svelte installed. Please Download svelte-particles to use tsParticles with a component ready to use and easier to configure.");
|
75 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/svelte/README.md");
|
76 | }
|
77 | }
|
78 |
|
79 | if (dependencies["inferno"]) {
|
80 | if (!dependencies["inferno-particles"]) {
|
81 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Inferno installed. Please Download inferno-particles to use tsParticles with a component ready to use and easier to configure.");
|
82 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/inferno/README.md");
|
83 | }
|
84 | }
|
85 |
|
86 | if (dependencies["preact"]) {
|
87 | if (!dependencies["preact-particles"]) {
|
88 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found Preact installed. Please Download preact-particles to use tsParticles with a component ready to use and easier to configure.");
|
89 | console.log("You can read more about the component here: https://github.com/matteobruni/tsparticles/blob/main/components/preact/README.md");
|
90 | }
|
91 | }
|
92 |
|
93 | if (dependencies["jquery"]) {
|
94 | if (!dependencies["jquery-particles"]) {
|
95 | console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found jQuery installed. Please Download jquery-particles to use tsParticles with a plugin ready to use and easier to configure.");
|
96 | console.log("You can read more about the plugin here: https://github.com/matteobruni/tsparticles/blob/main/components/jquery/README.md");
|
97 | }
|
98 | }
|
99 | } catch (error) {
|
100 | if (error.message === reactParticlesJsFoundError || error.message === particlesJsFoundError) {
|
101 | throw error;
|
102 | }
|
103 |
|
104 | console.log(error);
|
105 | }
|