New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inlang/paraglide-js

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inlang/paraglide-js - npm Package Compare versions

Comparing version 1.0.0-prerelease.4 to 1.0.0-prerelease.5

3

dist/cli/commands/init.d.ts

@@ -5,2 +5,5 @@ import { Command } from "commander";

export declare const initializeInlangProject: () => Promise<string>;
export declare const maybeAddVsCodeExtension: (args: {
projectPath: string;
}) => Promise<void>;
export declare const addParaglideJsToDependencies: () => Promise<void>;

@@ -7,0 +10,0 @@ export declare const promptForNamespace: () => Promise<string>;

@@ -29,2 +29,3 @@ import { Command } from "commander";

await addParaglideJsToDependencies();
await maybeAddVsCodeExtension({ projectPath });
consola.box("inlang Paraglide-JS has been set up sucessfully.\n\n1. Run your install command (npm i, yarn install, etc)\n2. Run the build script (npm run build, or similar.)\n3. Done :) Happy paragliding 🪂\n\n For questions and feedback, visit https://github.com/inlang/monorepo/discussions.\n");

@@ -43,2 +44,38 @@ });

};
export const maybeAddVsCodeExtension = async (args) => {
const response = await prompt(`Are you using VSCode?`, {
type: "confirm",
initial: true,
});
if (response === false) {
return;
}
const file = await fs.readFile(args.projectPath, { encoding: "utf-8" });
const stringify = detectJsonFormatting(file);
const settings = JSON.parse(file);
// m function matcher is not installed
if (settings.modules.some((m) => m.includes("plugin-m-function-matcher")) === false) {
// add the m function matcher plugin
settings.modules.push("https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js");
await fs.writeFile(args.projectPath, stringify(settings));
}
let extensions = {};
try {
extensions = JSON5.parse(await fs.readFile("./.vscode/extensions.json", { encoding: "utf-8" }));
}
catch {
// continue
}
if (extensions.recommendations === undefined) {
extensions.recommendations = [];
}
if (extensions.recommendations.includes("inlang.vs-code-extension") === false) {
extensions.recommendations.push("inlang.vs-code-extension");
if (fsSync.existsSync("./.vscode") === false) {
await fs.mkdir("./.vscode");
}
await fs.writeFile("./.vscode/extensions.json", JSON.stringify(extensions, undefined, 2));
consola.success("Added the inlang vs code extension to the workspace recommendations.");
}
};
export const addParaglideJsToDependencies = async () => {

@@ -135,3 +172,3 @@ const file = await fs.readFile("./package.json", { encoding: "utf-8" });

modules: [
// for instant gratification, we're adding the most common rules
// for instant gratification, we're adding common rules
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",

@@ -143,2 +180,4 @@ "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js",

"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
// the m function matcher should be installed by default in case the ide extension is adopted
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js",
],

@@ -145,0 +184,0 @@ "plugin.inlang.messageFormat": {

import { test, expect, vi, beforeAll, beforeEach } from "vitest";
import { addCompileStepToPackageJSON, addParaglideJsToDependencies, adjustTsConfigIfNecessary, checkIfPackageJsonExists, checkIfUncommittedChanges, createNewProjectFlow, existingProjectFlow, findExistingInlangProjectPath, initializeInlangProject, newProjectTemplate, promptForNamespace, } from "./init.js";
import { addCompileStepToPackageJSON, addParaglideJsToDependencies, adjustTsConfigIfNecessary, checkIfPackageJsonExists, checkIfUncommittedChanges, createNewProjectFlow, existingProjectFlow, findExistingInlangProjectPath, initializeInlangProject, maybeAddVsCodeExtension, newProjectTemplate, promptForNamespace, } from "./init.js";
import consola from "consola";

@@ -62,3 +62,3 @@ import { describe } from "node:test";

});
test("it should execute newProjectFlow() if not project has been found", async () => {
test("it should execute newProjectFlow() if no project has been found", async () => {
const { existsSync } = mockFiles({});

@@ -193,2 +193,60 @@ mockUserInput(["newProject"]);

});
describe("maybeAddVsCodeExtension()", () => {
test("it should add the vscode extension if the user uses vscode", async () => {
mockFiles({
"/project.inlang.json": JSON.stringify(newProjectTemplate),
});
mockUserInput([
// user uses vscode
true,
]);
await maybeAddVsCodeExtension({ projectPath: "/project.inlang.json" });
expect(consola.prompt).toHaveBeenCalledOnce();
const extensions = await fs.readFile("/.vscode/extensions.json", {
encoding: "utf-8",
});
expect(extensions).toBe(JSON.stringify({
recommendations: ["inlang.vs-code-extension"],
}, undefined, 2));
});
test("it should not add the vscode extension if the user doesn't use vscode", async () => {
mockFiles({
"/project.inlang.json": JSON.stringify(newProjectTemplate),
});
mockUserInput([
// user does not use vscode
false,
]);
await maybeAddVsCodeExtension({ projectPath: "/project.inlang.json" });
expect(consola.prompt).toHaveBeenCalledOnce();
expect(fs.writeFile).not.toHaveBeenCalled();
});
test("it should install the m function matcher if not installed", async () => {
const withEmptyModules = structuredClone(newProjectTemplate);
withEmptyModules.modules = [];
mockFiles({
"/project.inlang.json": JSON.stringify(withEmptyModules),
});
mockUserInput([
// user uses vscode
true,
]);
await maybeAddVsCodeExtension({ projectPath: "/project.inlang.json" });
const projectSettings = JSON.parse(await fs.readFile("/project.inlang.json", {
encoding: "utf-8",
}));
expect(projectSettings.modules.some((m) => m.includes("m-function-matcher"))).toBe(true);
});
test("it should create the .vscode folder if not existent", async () => {
mockFiles({
"/project.inlang.json": JSON.stringify(newProjectTemplate),
});
mockUserInput([
// user uses vscode
true,
]);
await maybeAddVsCodeExtension({ projectPath: "/project.inlang.json" });
expect(fsSync.existsSync("/.vscode/extensions.json")).toBe(true);
});
});
describe("createNewProjectFlow()", async () => {

@@ -195,0 +253,0 @@ test("it should succeed in creating a new project", async () => {

2

package.json
{
"name": "@inlang/paraglide-js",
"type": "module",
"version": "1.0.0-prerelease.4",
"version": "1.0.0-prerelease.5",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "publishConfig": {

@@ -1,3 +0,1 @@

# @inlang/paraglide-js
<!-- ## ATTENTION: Paraglide is in pre-release mode. Discuss the API at https://github.com/inlang/monorepo/discussions/1464 -->

@@ -15,2 +13,16 @@ <doc-links>

# Getting started
1. Run the following command in your terminal:
```bash
npx @inlang/paraglide-js@latest init
```
2. (If required) select an adapter.
## Available Adapters
- TODO: add adapters
# Usage

@@ -40,3 +52,3 @@

Paraglide JS exports four runtime variables and functions via "@inlang/paraglide-js":
Paraglide JS exports four variables and functions via "@inlang/paraglide-js":

@@ -49,37 +61,8 @@ - `sourceLanguageTag`: the source language tag of the project

# Getting started
## Available Adapters
- TODO: add adapters
## Standalone
1. Add paraglide as a dependency:
```bash
npm install @inlang/paraglide-js
```
2. Add the compiler to your build script:
```diff
{
"scripts": {
+ "build": "paraglide-js compile --namespace <namespace>"
}
}
```
| compile | [options] | | |
|---------|-------------|----------|----------------------------------|
| | --project | \<path\> | default: "./project.inlang.json" |
| | --namespace | \<name\> | required |
# Architecture
Inlang Paraglide JS leverages a compiler to emit a use-case optimized i18n library.
Inlang Paraglide JS leverages a compiler to emit vanilla JavaScript functions.
By leveraging a compiler, inlang Paraglide JS eliminates a class of edge cases while also being simpler, faster, and more reliable than other i18n libraries. The compiled runtime contains less than 50 LOC (lines of code) and is less than 1kb gzipped.
The emitted functions are often referred to as "message functions". By emitting message functions, inlang Paraglide JS eliminates a class of edge cases while also being simpler, faster, and more reliable than other i18n libraries. The compiled runtime contains less than 50 LOC (lines of code) and is less than 1kb gzipped.

@@ -86,0 +69,0 @@ Inlang Paraglide-JS consists of four main parts:

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc