Skip to content

Commit 554d0dd

Browse files
TommertomTommertom
authored andcommitted
remove unused http approach
1 parent 7709449 commit 554d0dd

File tree

3 files changed

+77
-211
lines changed

3 files changed

+77
-211
lines changed

package.json

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
{
2-
"name": "ionic-svelte",
3-
"version": "0.5.85",
4-
"private": false,
5-
"homepage": "https://ionic-svelte.firebaseapp.com",
6-
"repository": {
7-
"type": "git",
8-
"url": "https://github.com/Tommertom/svelte-ionic-app.git"
9-
},
10-
"keywords": [
11-
"ui library",
12-
"ui",
13-
"ionic",
14-
"svelte",
15-
"sveltekit",
16-
"vite"
17-
],
18-
"main": "index.ts",
19-
"module": "index.ts",
20-
"types": "index.d.ts",
21-
"bugs": {
22-
"url": "https://github.com/Tommertom/svelte-ionic-app/issues"
23-
},
24-
"description": "The NPM library to implement Ionic in any Svelte project - supporting SvelteKit and Svelte with Vite",
25-
"scripts": {
26-
"lint": "prettier --check . && eslint .",
27-
"format": "prettier --write ."
28-
},
29-
"type": "module",
30-
"devDependencies": {
31-
"prettier-plugin-svelte": "^3.2.6",
32-
"svelte": "^4.0.5"
33-
},
34-
"dependencies": {
35-
"@ionic/core": "^8.2.2",
36-
"swiper": "^9.2.4"
37-
}
38-
}
2+
"name": "ionic-svelte",
3+
"version": "0.5.85",
4+
"private": false,
5+
"homepage": "https://ionic-svelte.firebaseapp.com",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/Tommertom/svelte-ionic-app.git"
9+
},
10+
"keywords": [
11+
"ui library",
12+
"ui",
13+
"ionic",
14+
"svelte",
15+
"sveltekit",
16+
"vite"
17+
],
18+
"main": "index.ts",
19+
"module": "index.ts",
20+
"types": "index.d.ts",
21+
"bugs": {
22+
"url": "https://github.com/Tommertom/svelte-ionic-app/issues"
23+
},
24+
"description": "The NPM library to implement Ionic in any Svelte project - supporting SvelteKit and Svelte with Vite",
25+
"scripts": {
26+
"lint": "prettier --check . && eslint .",
27+
"format": "prettier --write ."
28+
},
29+
"type": "module",
30+
"devDependencies": {
31+
"prettier-plugin-svelte": "^3.2.6",
32+
"svelte": "^4.0.5"
33+
},
34+
"dependencies": {
35+
"@ionic/core": "^8.2.2",
36+
"swiper": "^9.2.4"
37+
}
38+
}

package.json.bak

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{
2-
"name": "ionic-svelte",
3-
"version": "0.5.83",
4-
"private": false,
5-
"homepage": "https://ionic-svelte.firebaseapp.com",
6-
"repository": {
7-
"type": "git",
8-
"url": "https://github.com/Tommertom/svelte-ionic-app.git"
9-
},
10-
"keywords": [
11-
"ui library",
12-
"ui",
13-
"ionic",
14-
"svelte",
15-
"sveltekit",
16-
"vite"
17-
],
18-
"main": "index.ts",
19-
"module": "index.ts",
20-
"types": "index.d.ts",
21-
"bugs": {
22-
"url": "https://github.com/Tommertom/svelte-ionic-app/issues"
23-
},
24-
"description": "The NPM library to implement Ionic in any Svelte project - supporting SvelteKit and Svelte with Vite",
25-
"scripts": {
26-
"lint": "prettier --plugin-search-dir . --check . && eslint .",
27-
"format": "prettier --plugin-search-dir . --write ."
28-
},
29-
"type": "module",
30-
"devDependencies": {
31-
"svelte": "^4.0.5"
32-
},
33-
"dependencies": {
34-
"@ionic/core": "^8.2.2",
35-
"swiper": "^9.2.4"
36-
}
2+
"name": "ionic-svelte",
3+
"version": "0.5.85",
4+
"private": false,
5+
"homepage": "https://ionic-svelte.firebaseapp.com",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/Tommertom/svelte-ionic-app.git"
9+
},
10+
"keywords": [
11+
"ui library",
12+
"ui",
13+
"ionic",
14+
"svelte",
15+
"sveltekit",
16+
"vite"
17+
],
18+
"main": "index.ts",
19+
"module": "index.ts",
20+
"types": "index.d.ts",
21+
"bugs": {
22+
"url": "https://github.com/Tommertom/svelte-ionic-app/issues"
23+
},
24+
"description": "The NPM library to implement Ionic in any Svelte project - supporting SvelteKit and Svelte with Vite",
25+
"scripts": {
26+
"lint": "prettier --check . && eslint .",
27+
"format": "prettier --write ."
28+
},
29+
"type": "module",
30+
"devDependencies": {
31+
"prettier-plugin-svelte": "^3.2.6",
32+
"svelte": "^4.0.5"
33+
},
34+
"dependencies": {
35+
"@ionic/core": "^8.2.2",
36+
"swiper": "^9.2.4"
37+
}
3738
}

scripts/generator.js

Lines changed: 4 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// using https://unpkg.com/@ionic/[email protected]/core.json
99
// using https://unpkg.com/@ionic/[email protected]/core.json
1010

11-
const fs = require("fs");
12-
const https = require("https");
11+
import fs from "fs";
12+
import https from "https";
1313

1414
const kebabize = (str) => {
1515
return str
@@ -248,140 +248,5 @@ export function testUserAgent(win: Window, expr: RegExp);
248248
});
249249
};
250250

251-
function download(res) {
252-
let data = "";
253-
res.on("data", (chunk) => {
254-
data += chunk;
255-
});
256-
res.on("end", () => {
257-
fs.writeFile(file, data, (err) => {
258-
if (err) throw err;
259-
console.log(`File saved as ${file} - length ${data.length}`);
260-
doStuff();
261-
});
262-
});
263-
}
264-
265-
function extractVersion(url) {
266-
const regex = /@(\d+\.\d+\.\d+)/;
267-
const match = url.match(regex);
268-
269-
if (match) {
270-
const version = match[1];
271-
// console.log(version); // Output: "7.0.3"
272-
return version;
273-
} else {
274-
console.log("No version number found");
275-
return "ERROR";
276-
}
277-
}
278-
279-
function bumpPackageJson(version) {
280-
const currentDirectory = process.cwd();
281-
282-
if (currentDirectory.includes("script")) {
283-
console.log(
284-
"Current directory contains the word 'script' - that is how we want it"
285-
);
286-
} else {
287-
console.log(
288-
"Current directory does not contain the word 'script' - aborting"
289-
);
290-
process.exit();
291-
}
292-
293-
const filePath = "../package.json";
294-
const packageName = "ionic-svelte";
295-
296-
fs.readFile(filePath, "utf-8", (err, data) => {
297-
if (err) throw err;
298-
299-
// make backup
300-
fs.writeFile(filePath + ".bak", data, "utf-8", (err) => {
301-
if (err) throw err;
302-
console.log(`Backup created of ${filePath}`);
303-
});
304-
305-
const packageJson = JSON.parse(data);
306-
307-
if (packageJson.dependencies && packageJson.dependencies[packageName]) {
308-
packageJson.dependencies[packageName] = version;
309-
} else if (
310-
packageJson.devDependencies &&
311-
packageJson.devDependencies[packageName]
312-
) {
313-
packageJson.devDependencies[packageName] = version;
314-
} else {
315-
console.log(
316-
`Package ${packageName} not found in dependencies or devDependencies`
317-
);
318-
}
319-
320-
const updatedPackageJson = JSON.stringify(packageJson, null, 2);
321-
322-
fs.writeFile(filePath, updatedPackageJson, "utf-8", (err) => {
323-
if (err) throw err;
324-
console.log(
325-
`Version of package ${packageName} updated to ${version}\n${updatedPackageJson}`
326-
);
327-
});
328-
});
329-
}
330-
331-
const url = "https://unpkg.com/@ionic/docs/core.json";
332-
const file = "core.json";
333-
334-
https.get(url, (res) => {
335-
if (res.statusCode >= 300 && res.statusCode <= 399 && res.headers.location) {
336-
// Redirect detected
337-
338-
console.log("redirect", res.headers.location);
339-
const version = extractVersion(res.headers.location);
340-
console.log("Version found", version);
341-
342-
bumpPackageJson(version);
343-
// bumpCreatorPackages(version, '../packages/create-capacitor-svelte-app/src/creator.js');
344-
// bumpCreatorPackages(version,'../packages/create-ionic-svelte-app/src/creator.js');
345-
346-
https.get("https://unpkg.com" + res.headers.location, (res) => {
347-
download(res);
348-
});
349-
} else {
350-
download(res);
351-
}
352-
});
353-
354-
function bumpCreatorPackages(version, fileName) {
355-
// Read the contents of the creator.js file
356-
357-
fs.readFile(fileName, "utf8", (err, data) => {
358-
if (err) {
359-
console.error(err);
360-
return;
361-
}
362-
363-
// make backup
364-
fs.writeFile(fileName + ".bak", data, "utf-8", (err) => {
365-
if (err) throw err;
366-
console.log(`Backup created of ${fileName}`);
367-
});
368-
369-
// Define the search and replace strings
370-
const searchStr = "['@ionic/core@";
371-
const replaceStr = "['@ionic/core@" + version;
372-
373-
// Use a regular expression to search and replace the desired string
374-
const regex = new RegExp(`${searchStr}\\d+\\.\\d+\\.\\d+'`, "g");
375-
const newData = data.replace(regex, replaceStr);
376-
377-
// Write the updated contents back to the file
378-
fs.writeFile("creasssstor.js", newData, "utf8", (err) => {
379-
if (err) {
380-
console.error(err);
381-
return;
382-
}
383-
384-
console.log("File updated successfully!");
385-
});
386-
});
387-
}
251+
doStuff();
252+
console.log("done!");

0 commit comments

Comments
 (0)